4 ms·
Java doesn't use system memory management by default, but rather keeps its own heap for garbage collection. If you start your java daemon with -Xms5000m -Xmx500
by RyanZAG 9y ago
Java doesn't use system memory management by default, but rather keeps its own heap for garbage collection. If you start your java daemon with -Xms5000m -Xmx5000m then java will use 5GB of ram and use that to allocate new objects inside it. Depending on the garbage collector used, Java may wait until that 5GB is full before clearing it out, therefore using "up to 5GB of RAM" for the same 50MB dataset in a long running process.
It's not really a useful comparison for most uses of java though.