Reputation: 7782
Is there a way to know what type of objects are being garbage-collected the most in a Javascript application?
I do know I can get Heap Snapshot but that only tells what objects are the most common, not the most garbage-collected.
And Heap Allocations do not give detailed information about Object class.
Upvotes: 8
Views: 128
Reputation: 5656
I guess you can do this by taking multiple heap snapshots and then comparing the snapshots to identify which objects are being grabage collected. You can refer to this answer. Hope it helps :)
Upvotes: 1
Reputation: 1509
Using which JavaScript runtime engine? Each engine will have its own GC and its own way of monitoring GC events. The Chrome V8 engine would be a good place to start if you are trying to learn more about one GC implementation: https://developers.google.com/v8/ If you pull in the source from github https://chromium.googlesource.com/v8/v8.git you will find files src/heap/gc-tracer.[h|cc] provide a lot of capability, and you could add more for your own profiling needs.
Upvotes: 0