I'm trying to host Swing Java application for a lengthy period on VPS at "always-on" mode and am willing to fit it into 1GB shape (Ubuntu as host OS).
Application is started with "-Xmx500m -XX:+UseConcMarkSweepGC" and it seems reasonable that it should fit (with all other supplementary staff) into 1GB of total RAM, but ... after running application for 2-3 days top
says that java application alone eats almost 1GB (see USED column) - it is twice more than specified "-Xmx500m":
KiB Mem : 1009136 total, 66084 free, 867128 used, 75924 buff/cache
KiB Swap: 716796 total, 9388 free, 707408 used. 28472 avail Mem
PID VIRT RES SWAP USED SHR S %CPU %MEM TIME+ COMMAND
2401 3076084 529648 467832 997480 1900 S 31.0 52.5 916:05.68 java
2218 285544 37548 74720 112268 8800 S 6.9 3.7 269:12.60 Xvnc4
2388 709104 11448 9744 21192 7760 S 6.9 1.1 24:45.88 mate-terminal
883 643820 10932 2540 13472 5624 S 0.0 1.1 1:48.43 do-agent
2327 544648 4092 5992 10084 2436 S 3.4 0.4 6:38.31 clock-applet
Actual 'Heap usage' within application is around 350MB (displayed by application itself).
From jstat -gc 2401
I see usage only of around 630MB. Where are other ~360MB? What I'm missing? Is it possible to reduce memory usage via some JVM options?
S0C S1C S0U S1U EC EU OC OU
8512.0 8512.0 0.0 2161.2 68160.0 67668.5 426816.0 249483.9
MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
112464.0 108027.1 14160.0 13222.6 48701 1484.856 124 590.113 2074.968
https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jstat.html
S0C - Current survivor space 0 - 8MB
S1C - Current survivor space 1 - 8MB
EU - Current eden space capacity - 68 MB
OC - Current old space capacity - 426 MB
MC - Metaspace capacity - 112 MB
CCSC - Compressed class space capacity - 14 MB
--> 636 MB