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

"Number Of Objects in Heap"

 
subhadeep chakraborty
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do i find the number of objects currently placed in the heap?
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In an ordinary Java application, you can't.

Using the monitoring/debugging APIs, you can, but I am no expert in using those. Alternatively, you can use a profiler/monitor program. Certainly, JProfiler would tell you. I think some of Sun's free tools will, too.

For what purpose do you need this information?
[ August 23, 2007: Message edited by: Peter Chase ]
 
subhadeep chakraborty
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am new to java and i am not using it so, it would be helpful if you could tell some easy way to find.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In general, there is no easy way to get this info, and you don't need it.

If you really want the answer anyway, the easiest way is probably to find an IDE or profiler that gives you this information. Personally I've never had any reason to track down that info, so I can't help you there.

But again, in all likelihood, you really don't need it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic