This content has been marked as final. Show 3 replies
What is it that you're trying to accomplish?
What problem is it that you have, where you think the solution is to get a list of every instantiated object?
What are you planning to do with that list?
Even a very small, short-lived program can easily create hundreds or thousands of objects during its lifetime, so it's unlikely that a complete list will be of any practical use.
If you want to observe, for example, which objects are consuming the majority of your memory because you're trying to reduce the memory footprint, you could use a profiler, such as JProbe, JProfiler, OptimizeIt, or VisualVM.
Actually I have a Tool which checks for a particular type of object and takes some action on it. I want to invoke that tool via my java program on run time and check for that particular type of object. That's why I want a complete list of objects through which I will iterate and invoke my tool if that particular object type is found.