Getting to know used memory without garbage collectable objects

Hi all,I would like to know what is the currently used memory without garbage, so only the objects that are still referenced.Is there a way to do that? Preferably using JConsole?Thanks,Kristof
[227 byte] By [kad_taa] at [2007-11-26 19:28:08]
# 1
One way is to call force gc and then see how much memory is used.This may give you the memory usage without a garbage.I think jconsole has an force gc option. I am not sure. Check thejconsole doc.
swamyva at 2007-7-9 21:55:17 > top of Java-index,Core,Monitoring & Management...
# 2

That is indeed a way but the problem is that you are never sure that all garbage will get collected... (JConsole indeed has a Force GC button)

I suspect that the JVM only knows the amount of garbage when it performs a GC. And as this is an expensive operation is would not be effective from a performance point of view to constantly keep track of the amount of garbage in the heap. That is probably also the reason why there is no profiler that supports this.

It makes it difficult to get to know the actual memory gain from one implementation versus another. The most reliable way to go I think is by running the application several times, lowering the max heap each time till it fails with OutOfMemoryException.

kad_taa at 2007-7-9 21:55:17 > top of Java-index,Core,Monitoring & Management...