java run out of memory issue

前端 未结 6 2163
自闭症患者
自闭症患者 2021-01-04 13:13

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

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-04 13:39

    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

提交回复
热议问题