Java -Xmx, Max memory on system

后端 未结 7 1311
没有蜡笔的小新
没有蜡笔的小新 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:29

    If you haven't done so already, you need to run your program through a memory profiler. You might find that certain data structures aren't being disposed of, even though they're no longer being used.

    JProfiler is pretty nifty, but you can get the same information using HPROF, which was introduced in Java 5: http://java.sun.com/developer/technicalArticles/Programming/HPROF.html

    Keep in mind also that different platforms have different maximum heap sizes, based on architecture (32-bit vs 64-bit), OS, and even the JVM.

    If you have a lot of values that may be reused (such as strings you're reading in from an XML file), you could get a huge decrease in memory requirements by pooling your objects.

提交回复
热议问题