Hi All I want to track the number of objects created and memory used during the execution of a java program.I want to implement it as a thread which will concurrently run with the application Can anybody help me in this regard
Just a thought: Create a separate thread to run concurrently with the main thread. Every time the main thread creates an object that you want to track, it increments a static counter. The other thread has only to display that counter.
Yes that is my idea even. But how will i know wheather an object has been created by the main method Any special classes in java which can detect the creation or initialization of objects
There are some profiling tools that support this feature. If you want to do it yourself, it can be done but not easily. You have to override the Object class. This will catch the construction of every object (except arrays) unless they are created with clone(). The book "Java Performance Tuning" discusses this if you can get your hands on a copy.
Originally posted by Shyam Purkayastha: a few monitering utilities available for java
I would be happy if only one exists. No I cannot name any. Maybe none exists. JVM controls execution of threads, which may run concurrently but independent of one another. If there is any monitoring exist, it must come JVM itself.