Why does Linux allocate so much virtual memory for Java compared to the heap size?

@Middleware & OS Hey guys, Why does Linux allocate so much virtual memory for Java compared to the heap size? Is there a way to fix this? Windows seems to behave differently I tried setting a smaller heap (128 MB) but virtual memory stays high (210 MB). -Default heap size: 64 MB -Virtual memory used: 240 MB (causing problems!) ulimit -v doesn't help - setting it too low prevents the app from running.
2 Replies
UC GEE
UC GEE5mo ago
The vm.overcommit_ratio setting controls how much virtual memory is allocated compared to the available physical memory. A higher value can lead to overcommitting, which can cause the system to run out of memory.But, you can fix it by adjusting the vm.overcommit_ratio setting to prevent overcommitting. @Dtynin
barafael
barafael5mo ago
The JVM preallocates memory to manage it itself. This is one reason why naive Java programs are sometimes faster than naive C programs. You can configure the JVM heap size at startup
Want results from more Discord servers?
Add your server