Hi community,
I am trying to explore the memory behaviour of an application (standalone GUI) after customer complaing of great memory usage (application works on terminal server, so several terminal clients whth big memory consumption eat up all memory).
The memory dynamic is like this: there are memory consuming tasks, so there is a need for more available memory (i.e. Xmx128M) but in general there is no need for so much memory, but at most 40-50 MB instead. However after a heavy task the memory is 'filled up' and never freed, though not needed.
The
test code below simulates user task that requires memory and after that continues in 'low-memory mode'. However I found out that I need to explicitly call System.gc() /a practice that is discouraged as I have read/ in order to restore the memory state to 'normal' state after the high-requirement task was completed. Strange is that if there is no allocation of bigger resources there are no garbage collections if there is no gc() call /as the second log shows/.
The question is what are the parameters to tell the JVM to behave so that the memory allocation(total seen in OS performance meters) follows at least roughly the real required memory?
I checked a
recent thread but did not find the mentioned parameters.
Code below is the test code that produces the both logs below, with and without the System.gc() call on indicated line 45.
Thanks for your attention and your tips
Mike
TEST CODE: Performance.java
~:TEST CODE
Run with explicit System.gc() on line 45
-------------------------------------------
java -verbose:gc -Xms1M -Xmx20M -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 Performance
0.9375(4)
0.9375(4)
[GC 123K->84K(960K), 0.0032387 secs]
[Full GC 84K->84K(960K), 0.0065660 secs]
[Full GC 8276K->8276K(9156K), 0.0071989 secs]
9.734375(48)
[GC 8277K->8276K(9968K), 0.0006322 secs]
[Full GC 8276K->8276K(9968K), 0.0067376 secs]
[Full GC 16468K->8276K(18164K), 0.0153724 secs]
18.30078125(92)
[Full GC 16468K->8276K(18740K), 0.0142714 secs]
17.55078125(88)
[Full GC 16468K->8276K(17972K), 0.0144490 secs]
14.94921875(75)
[GC 8276K->8276K(15308K), 0.0001583 secs]
[Full GC 8276K->8276K(15308K), 0.0071805 secs]
[Full GC 16468K->8276K(19376K), 0.0144972 secs]
10.91796875(54)
[Full GC 8276K->8276K(11180K), 0.0069838 secs]
10.91796875(54)
[Full GC 8276K->8276K(11180K), 0.0068601 secs]
10.91796875(54)
[Full GC 8276K->8276K(11180K), 0.0053297 secs]
Run without explicit System.gc() on line 45
-------------------------------------------
java -verbose:gc -Xms1M -Xmx20M -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 Performance
0.9375(4)
0.9375(4)
[GC 123K->84K(960K), 0.0034072 secs]
[Full GC 84K->84K(960K), 0.0071337 secs]
8.94140625(44)
[GC 8277K->8276K(9156K), 0.0006473 secs]
[Full GC 8276K->8276K(9156K), 0.0068225 secs]
17.73828125(89)
[GC 16469K->16468K(18164K), 0.0002155 secs]
[Full GC 16468K->8276K(18164K), 0.0143771 secs]
18.30078125(92)
[GC 16469K->16468K(18740K), 0.0002150 secs]
[Full GC 16468K->8276K(18740K), 0.0157676 secs]
17.55078125(88)
[GC 16468K->16468K(17972K), 0.0002160 secs]
[Full GC 16468K->8276K(17972K), 0.0148848 secs]
19.625(98)
19.625(98)
19.625(98)
19.625(98)
19.625(98)
19.625(98)
19.625(98)
19.625(98)
19.625(98)
19.625(98)
19.625(98)
19.625(98)
19.625(98)
19.625(98)
19.625(98)
19.625(98)
19.625(98)