File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Tool to view Heap Memory in real time

Vijaykumar Ramalingam

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;
Bank b;
for(int i=0 ; i< 1million; i++){
b = new Bank();

fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11952

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

Joined: Mar 22, 2005
Posts: 42965
VisualVM is a great tool for that. Its VisualGC (or something like that) plugin shows a lot of interesting graphs.
I agree. Here's the link:
subject: Tool to view Heap Memory in real time
It's not a secret anymore!