Java -Xmx, Max memory on system

后端 未结 7 1360
没有蜡笔的小新
没有蜡笔的小新 2020-12-15 05:01

My Java application runs another Java application, by running the process \"java -jar j.jar\". J.jar is known to use a LOT of memory depending on the dataset it is given, an

7条回答
  •  甜味超标
    2020-12-15 05:30

    Well, one thing I can tell you is don't let your app get close to filling up ram. Java apps don't swap gracefully at all. I think because of Garbage Collection, java constantly pulls its memory from swap.

    I ran into a deadlock where I think the system was asking java for memory which would cause a GC and pull stuff out of the swapfile--at this point the system would just spin until I reset it.

    This was with a LOT of ram and a LOT of swap space (for the time) and an older Java VM, so your mileage may vary.

    Also, depending on how you are starting that other app, you may have to specify -Xms for your app instead of the other one. If you are giving it a full command, give it the -Xms, but if you are simply calling the main class in the jar, then your app needs the -Xms. (Oh, you specified, yeah you need to pass it into the "Java" command you are calling. )

提交回复
热议问题