Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serialize HotSpot State

Tags:

java

jvm

What are the technical reasons that there isn't a way to save some sort of image of JVM after having warmed it up? Assuming that I want to resume on same platform (so any JIT stuff would still work).

like image 701
aamit915 Avatar asked Oct 12 '15 00:10

aamit915


1 Answers

Depending on which JVM you use there is such functionality already. JRockit is reported to be able to, for the "normal" consumer JRE a JEP 145 existed but obviously did not make it.

There are some questions about this topic already here on SO, try this one for example.

For the regular Oracle JVM no such function exists, you may fiddle with the CodeCache to have it compile functions at the earliest time possible or "warm up" your JVM.

A persisted JVM cache carries some risks, like is the case with all caches. The JIT state will need to be invalidated and recalcuated when your code changes. If this would not happen you would run your program with the old code. This seems to be the primary reason why this disk persisted cache is limited to the "professional" JVM. Also the JIT optimization happening at start time is consider to be fast enough to repeat it at every start thereby eliminating the risk of running with outdated code.

like image 93
Marged Avatar answered Sep 28 '22 15:09

Marged