I have a strange behaviour on my application. When I launch my application with -Xmx<MEM>, it seems to use all the <MEM> specified, even if I invoke the garbage collector using jconsole.
I've also tried using jprofiler and heap dump: using jprofiler, I don't see where all the memory is used, even if I have no filter; using the heap dump, I get the file the same size as the eccupied memory, but, when analyzing with jprofiler, I don't see all the allocated variables, but far less data.
I've got some more details about my problem: a part of (most of) the heap is NOT reachable so it should be eligible for garbage collection; instead, I get OutOfMemoryError .
I supposed it was caused by weak references, but it is not possible, because jvm should release them before throwing OutOfMemoryError.
The permgen space should be enough (I've set it to an high value).
It seems to be an hibernate problem, which
1. creates some soft references without removing them, so the garbage collector sometimes decides to remove them
2. keeps a lot of java.lang.ResultSet references because of a bug
After solving the two problems, I had no more memory consumption.