I have a JAVA process that runs every day and takes about 1,000 or 2,000 hits before it is fully optimized by the JIT. What I'd like to do is save the JIT info so that the next day it can start in an optimized state. It seems like this should be possible, but I have not been able to find any method for doing so.
You could use an ahead-of-time compiler like JET or GCJ, but I don't believe there's any standard way to save the JIT form. Keep in mind that this ties your program into the architecture you're running on, but it sounds like you're aware and accepting of this.
One option is to control the number of invocations needed for a method to be considered eligible for JIT compile.
-XX:CompileThreshold (default 10000).
You could play around various values to tune up with your application.
Please note that setting this to ZERO is NOT recommended.
Can you just keep your app running? What happens if you just have your app sleep until the next day rather than shutting down? You will then save time starting up the JVM as well as potentially skipping the jitting phase.
来源:https://stackoverflow.com/questions/2178640/is-there-a-way-to-save-the-java-jit-information-for-the-next-run-so-that-i-dont