-
Notifications
You must be signed in to change notification settings - Fork 194
Fix tracing of allocations from C #2403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
In general I feel
So I think of it as something that should only be used for debugging. One thing we could do to make it a little bit less horrible would be to store allocation information on the DynamicObject iself, instead of on a separate Hash which leaks all allocations done while enabled. Self-note: the |
require_relative '../../spec_helper' | ||
require 'objspace' | ||
|
||
describe "ObjectSpace.memsize_of_all" do |
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.
The docs of this say:
This method is only expected to work with C Ruby.
But it seems we already implement it.
Anyway I think adding specs for it is fine, it doesn't seem worse than ObjectSpace.each_object
.
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.
We implement quite a bit more of objspace
in random ways.
describe "ObjectSpace.memsize_of_all" do | ||
it "returns a non-zero Integer for all objects" do | ||
ObjectSpace.memsize_of_all.should be_kind_of(Integer) | ||
ObjectSpace.memsize_of_all.zero?.should be_false |
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.
ObjectSpace.memsize_of_all.should > 0
seems more expressive and clearer, I'll change to that.
But as you say, not really worth improving it unless a need is seen. I'm fixing a crash here, that's all. |
I had the same idea and implemented that. |
…cing information directly on RubyDynamicObject (#2403) PullRequest: truffleruby/2804
We get failures while tracing allocations from C extensions. I think this fixes it, but I'm not keen to try to architect a test case, to be honest.