For the hello world app you can probably set -Xms and -Xmx to 5m, so java -Xms5m -Xmx5m Program. Xms sets the initial heap size, Xmx sets the max. There are lots of memory areas besides the heap though, as mentioned in the above post, so this will still use maybe 50MiB of memory or more.
As for figuring out what you should set for a given program, that generally takes a bit of profiling while the app is running with tools like jmap, jconsole, visualvm etc... Or just plain trial and error in some cases.
Creating a new Social Platform that will give developers something cool to build new apps on. My goal is to create an app to help people advertise their causes, apps etc. for free
I have to go through this soon with a Scala app I have 8Gb at least on a local testing server but my desktop has 16Gb I may try to up my server memory I think it maxes at 32Gb it is an ancient server I built with dual 2mhz AMD dual cores and 8 slots for memory. I built it for like $50
I wrote a post a while back that goes into a bit of depth around jvm memory usage, see
JVM Internals: Memory Overview
Stephen O'Brien ・ Jan 22 ・ 12 min read
For the hello world app you can probably set
-Xms
and-Xmx
to 5m, sojava -Xms5m -Xmx5m Program
. Xms sets the initial heap size, Xmx sets the max. There are lots of memory areas besides the heap though, as mentioned in the above post, so this will still use maybe 50MiB of memory or more.As for figuring out what you should set for a given program, that generally takes a bit of profiling while the app is running with tools like jmap, jconsole, visualvm etc... Or just plain trial and error in some cases.
I have to go through this soon with a Scala app I have 8Gb at least on a local testing server but my desktop has 16Gb I may try to up my server memory I think it maxes at 32Gb it is an ancient server I built with dual 2mhz AMD dual cores and 8 slots for memory. I built it for like $50
Thank you very much, very informative post! :)
I'm going to learn one of those tools, right now I feel clueless about anything related to memory
There is definitely a lot to learn, I'm still learning new things most days! Good luck 👍
I'm going to do a more practical post around tuning the jvm soon.