java - Going through every object in program using reflection -
i want write cost analysis method number of different classes count number of times objects have been created. easy way increment variable in constructors each of them, wondering if it's possible go through every object in use using reflection?
here's 2 ways this:
- install java agent jvm, can stuff monitor object creation
- create own classloader can delegate actual object creation work default classloader, count objects they're created.
neither solution particularly easy implement.
i'd go java agent, because doesn't require changes application code - instead injected jvm @ runtime.
edit: alternatively, learn use java profiler, visualvm.
Comments
Post a Comment