Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tool to view Heap Memory in real time

 
Vijaykumar Ramalingam
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12145
30
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
VisualVM is a great tool for that. Its VisualGC (or something like that) plugin shows a lot of interesting graphs.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic