from http://code.google.com/p/fast-serialization/wiki/QuickStartHeapOff
What is a dump heap?
Usually all non-temporary objects that you assign are managed by the java garbage collector. Although the VM does a decent job of collecting garbage, at some point the VM should do the so-called “Full GC”. A full GC includes scanning the entire allocated heap, which means that the GC pauses / slows are proportional to the size of the application heap. Therefore, do not trust anyone telling you that "Memory is cheap." In java memory, consumption degrades performance. In addition, you can get noticeable pauses using heap sizes> 1 GB. This can be frustrating if you have things in almost real time, in a cluster or grid, the java process may not respond and be dropped from the cluster.
However, today's server applications (often built on thieves frameworks ;-)) easily require heaps far beyond 4Gb.
One solution to these memory requirements is to "unload" parts of objects into a non-java heap (directly allocated from the OS). Fortunately, java.nio provides classes for directly allocating / reading and writing "unmanaged" pieces of memory (even with memory mapping).
Thus, you can allocate large amounts of "uncontrolled" memory and use it to save objects. To store arbitrary objects in unmanaged memory, the most viable solution is to use serialization. This means that the application serializes the objects into offheap memory, later the object can be read using deserialization.
The heap size controlled by the Java virtual machine may be small, so GC pauses are in milliseconds, everyone is happy with the work.
It is clear that the performance of such a heap buffer depends mainly on the performance of serialization implementation. Good news: for some reason, serializing FST is pretty fast :-).
Examples of use cases:
- Session cache in the server application. Use a memory mapped file to store gigabytes of (inactive) user sessions. Once a user enters your application, you can quickly access data related to the user, without having to deal with a database.
- Caching of computational results (queries, html-pages, ..) (applicable only if the calculation is slower than deserializing the result object from c).
- very simple and quick save using memory mapped files
Edit: For some scenarios, you can choose more sophisticated garbage collection algorithms such as ConcurrentMarkAndSweep or G1 to support large heaps (but it also has its limits beyond 16 GB). There is also a commercial JVM with improved "inconclusive" GC (Azul).
R.Moeller Dec 15 '12 at 17:31 2012-12-15 17:31
source share