How can I disable Java garbage collector?

后端 未结 8 1154
你的背包
你的背包 2020-12-08 19:16

We have a PHP webapp that calls a Java binary to produce a PDF report (with JasperReports). The Java binary outputs the PDF to standard output and exits; the PHP then sends

8条回答
  •  时光取名叫无心
    2020-12-08 19:37

    There is no way to disable garbage collection entirely. Garbage collection is only run when the JVM runs out of space, so you could give the program more memory. Add these command line options to the Java command

    -Xmx256M -Xms256M
    

    This gives the program 256Mb of ram (the default is 64Mb). Garbage collection will not take 3 seconds for a default size JVM though, so you might want to investigate more closely what the program is doing. Yourkit profiler is very useful for figuring out what is taking a long time.

提交回复
热议问题