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:

  1. install java agent jvm, can stuff monitor object creation
  2. 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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -