I have a jar file running on an amazon-ec2-m1.large instance with linux 64bit operating system. I run out of memory after different hours, usually between 2-4, although in m
Please try 64 bit version of Java if you are using 32 bit version,
Also add new JVM argument , "-XX:+CMSClassUnloadingEnabled \ " which clear some unused class objects
I was able to resolve an almost identical error by following the advice given by:
https://confluence.csiro.au/pages/viewpage.action?pageId=278167841
Essentially, they state:
When the Java Virtual Machine starts, by default it spawns a number of Garbage Collection (GC) threads, which are used for parallel GC operations … the number of such threads is calculated by this formula: (ncpus <= 8) ? ncpus : 3 + ((ncpus * 5) / 8) … Because of the creation of these many threads … the program will automatically reach the system limit …
I limited the number of garbage collecting threads using the environment variable, like so:
export _JAVA_OPTIONS="-XX:ParallelGCThreads=2"
Not sure about the overall performance hit regarding GC, but at least today's work is done.
Please check the original post for more options.
Good Luck, - Stu
Heap is only part of the equation. Have a look at total resident memory - it includes heap and off heap contributions. Off heap includes mapped JARs, thread stacks (~1MB per thread), perm gen, etc. SO has a number of questions on how to do it on Linux.
If you have more physical ram available use that . It seems that the heap size allocated is only 1656 mb which perhaps is not enough. Try running java jar file with two switches -xmx4096mb and -xms 2048 Then monitor the usage , perhaps the memory requirement is too large for your application , if you still run out of memory after sometime then it needs further investigation to check if your code is leaking memory. Hope this helps , let me know if you need more clarification
Solved with the latest jdk.
Please try installing java-11-openjdk
Without trying to decode the dump data, I'll observe that there are basically three cases for running a JVM out of memory:
Kind of in-between here would be classes. If you run a app that dynamically creates and loads classes, you must properly use individual class loaders to make the classes collectable.