java.lang.OutOfMemoryError: Java heap space

前端 未结 11 1063
温柔的废话
温柔的废话 2020-11-22 08:01

I am getting the following error on execution of a multi-threading program

java.lang.OutOfMemoryError: Java heap space

The above error occu

11条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 08:51

    1.- Yes, but it pretty much refers to the whole memory used by your program.

    2.- Yes see Java VM options

    -Xms        set initial Java heap size
    -Xmx        set maximum Java heap size
    

    Ie

    java -Xmx2g assign 2 gigabytes of ram as maximum to your app

    But you should see if you don't have a memory leak first.

    3.- It depends on the program. Try spot memory leaks. This question would be to hard to answer. Lately you can profile using JConsole to try to find out where your memory is going to

提交回复
热议问题