Skip to content
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

Improve usage of ObjectSpace to include the classes of the objects #4

Open
kevinjalbert opened this issue Jan 11, 2016 · 0 comments
Open

Comments

@kevinjalbert
Copy link
Owner

rake-mini-profiler has an profile-gc option which exposes finer memory allocation details. Most notability is that it shows the classes of the objects. This can be extracted using:

ObjectSpace.each_object.map{ |x| x.class.name }

This code will enumerate over all the objects in the ObjectSpace. From this we can more accurately store the number of objects from specific classes.


As a part of this improvement we should improve the way we store the individual object types in the ObjectSpaceStats. As we will be encountering dynamic object types we should instead of using fixed instance variables (i.e., string_count_collection), we should have an object_class_counts:

{
  "String" => [ 10, 12, 31],
  "NewRelic::Agent::NewRelicService::JsonMarshaller" => [1, 4, 3],
  "Integer" => [ 1, 1, 3],
  "RubyVM::InstructionSequence" => [3, 1, 1],
  ...
}

This should also simplify some of the verbosity of the source and specs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant