This repository has been archived by the owner on Dec 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 193
ensure idenity map entries are cleaned up: #384
Open
cowboyd
wants to merge
1
commit into
upgrade-to-v8-4.5
Choose a base branch
from
4.5/fix-weakmap-entry-leakage
base: upgrade-to-v8-4.5
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
require 'spec_helper' | ||
|
||
describe "Identity Mapping Memory Usages" do | ||
it "does not leak memory by virtue of maintaining an identity map" do | ||
## | ||
# This verifies that the identity map which is holds on to the | ||
# mappings between v8 objects and ruby objects does not leak its | ||
# entries as originally reported by this ticket: | ||
# https://github.com/cowboyd/therubyracer/pull/336 | ||
# | ||
# Without the patch, while the v8 object was not being leaked, the | ||
# entry in the identity map was. This test injects 5000 objects | ||
# into the v8 context 20 times over, which will generate 5000 | ||
# unique proxies. All of these proxies should be immediately released. | ||
|
||
require 'memory_profiler' | ||
|
||
def rss | ||
`ps -eo pid,rss | grep #{Process.pid} | awk '{print $2}'`.to_i | ||
end | ||
|
||
cxt = V8::Context.new | ||
Object.new.tap do |o| | ||
cxt["object-#{o.object_id}"] = o | ||
cxt["object-#{o.object_id}"] = nil | ||
end | ||
|
||
# MemoryProfiler has a helper that runs the GC multiple times to make | ||
# sure all objects that can be freed are freed. | ||
MemoryProfiler::Helpers.full_gc | ||
|
||
start = rss | ||
#puts "rss: #{rss} live objects #{GC.stat[:heap_live_slots]}" | ||
|
||
20.times do | ||
|
||
5000.times { |i| | ||
Object.new.tap do |o| | ||
cxt["object-#{o.object_id}"] = o | ||
cxt["object-#{o.object_id}"] = nil | ||
end | ||
while cxt.isolate.native.IdleNotificationDeadline(0.1); end | ||
} | ||
MemoryProfiler::Helpers.full_gc | ||
#puts "rss: #{rss} live objects #{GC.stat[:heap_live_slots]}" | ||
|
||
end | ||
finish = rss | ||
|
||
expect(finish).to be <= start * 2.5 | ||
end if RUBY_VERSION >= "2.1.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm... Wouldn't it be nicer if we just put the example in a
pending
state with a message that it should only be run only newer versions of ruby?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, probably so. I'll fix that.