2

I have a Debian server that I'm really cheaping out on, but for some reason the Java processes use all the memory then throw a "OutOfMemoryError" rather than using the swap space.

I've got 1GB of Swap, and htop will show 0/1024M in usage no matter what I do.

I've tried using sudo sysctl vm.swappiness=100, but the swap space still doesn't get used

As an additional point, sudo swapon --show displays:

NAME      TYPE  SIZE USED PRIO
/swapfile file 1024M   0B   -1

(and the chmod permissions are set to 600), So I believe my swapfile is working.

Anyone have any ideas? Thanks!

0
3

I don’t think this is a Linux problem. Java has its own memory limits that are nothing to do with the OS. I believe you are seeing these errors because of java’s own limit.

Different JVMs have different options. You're using Debian so it's likely you're using OpenJDK. Though it's still possible you're using oracle's JVM. OpenJDK's default max heap size is 256MB, so unless you are running on really small RAM or a lot of Java processes, it's quite likely you will hit Java's own limit before you ever start using swap.

Answers here may give more info if you are using Oracle's JVM https://stackoverflow.com/questions/4667483/how-is-the-default-max-java-heap-size-determined

I'd try adjusting the "max heap size" by running your Java programs with -Xmx. This option is described here: https://wiki.openjdk.java.net/display/zgc/Main

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.