aspose file tools*
The moose likes Performance and the fly likes Is there any means to check the number of objects created when a java prgram runs. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "Is there any means to check the number of objects created when a java prgram runs. " Watch "Is there any means to check the number of objects created when a java prgram runs. " New topic
Author

Is there any means to check the number of objects created when a java prgram runs.

Vinoth Maharaj
Greenhorn

Joined: Oct 19, 2011
Posts: 3

I need to check the number of objects created by this java program.

class Test{

public static void main(String args[]){
System.out.println("Hello World !");
}

}


Never try to win others, win yourself.
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2332
    
  28

You can use any profiler. I believe VisualVM can show you the objects. Or if you don't want to download anything, you can use JMXConsole to take a heap dump
Tina Smith
Ranch Hand

Joined: Jul 21, 2011
Posts: 171
    
    5

Doesn't VisualVM come with the JDK?


Everything is theoretically impossible, until it is done. ~Robert A. Heinlein
Alfred Peterson
Greenhorn

Joined: Aug 17, 2010
Posts: 12
I have been used VisualVM but not for counting number of objects. I think, you can use it.


emule
Ove Lindström
Ranch Hand

Joined: Mar 10, 2008
Posts: 326

The question has been answered before.

http://www.coderanch.com/t/329407/java/java/find-all-loaded-classes-classloaders
 
Consider Paul's rocket mass heater.
 
subject: Is there any means to check the number of objects created when a java prgram runs.