I\'m currently testing my proof of concept prototype dealing with XML schema, and built around a very memory consuming external library for tree automata (for which I\'ve got th
1) System.gc() "suggest" a GC run, does not force it in any way, so it is not possible to rely on it for detecting memory usage peaks
Thats what the spec says but if you use OpenJDK or HotSpot it will always perform a Full GC unless you turn it off.
What is usually suggested is to count object occupation
I would suggest using a commercial memory profiler. I would have the JVM start with a maximum of 8 GB and see how much it tries to use. After that I would increase or decrease it based on your judgement on whether it would like more or doesn't appear to be using it.
There is no way to easily obtain the memory occupation of a method (expressed as the peak of object memory allocation)
The only memory a method uses is on the stack. You can trace how much objects (count,classes,size) where creating in a method but those objects don't belong to that method and can be used anywhere, even after the method has returned.
If not, how do you explain the "deterministc behaviour" of that button?
I would put that down to subjective analysis. ;)
Ideally you should be running the JVM with 2-3x the minimum memory it needs for it to run efficiently. Trying to save a few 100 MB which cost less than $1 is not always useful. ;)