aspose file tools*
The moose likes Performance and the fly likes Tool to view Heap Memory in real time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "Tool to view Heap Memory in real time" Watch "Tool to view Heap Memory in real time" New topic
Author

Tool to view Heap Memory in real time

Vijaykumar Ramalingam
Greenhorn

Joined: Mar 03, 2011
Posts: 15
Hello All,
I need help to view heap memory in real time and Visualize Garbage Collection as it happens when I create 1million objects.
For the following program below
I want to view analyze how the memory is occupied in the Heap
class Bank{
int balance;
String details;
main(){
Bank b;
for(int i=0 ; i< 1million; i++){
b = new Bank();
}
}
Thanks,
-Vijay

fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11314
    
  16

To what purpose?

I am not an expert, but this seems like a waste of time. One of the major benefits of java is that you don't have to worry about memory management. And, you can't even be sure the GC will run with this (or any) program.

And further, you don't know it will be the same from run to run, so seeing how it works once is no guarantee that it will be anything similar the next time.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41873
    
  63
VisualVM is a great tool for that. Its VisualGC (or something like that) plugin shows a lot of interesting graphs.


Ping & DNS - my free Android networking tools app
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Tool to view Heap Memory in real time