tl;dr Below, both cases involved fighting with either garbage collector, or wanting greater control over paging:
Project 1:
With the ESPER correlation engine, you can feed a sequence of Map implementations to it, but it can hold on to them for arbitrary long periods of time (depending on what ESPER statements you have configured). Without care, you can easily exhaust heap. And the access pattern usually is: Look at an object once, hold onto it for a long time (days), and then look at it again later and let go of it, with object access usually having "stream" locality of reference from one to the next.
Approach was to write "guts" of Map to mem-mapped file, but hand flyweight Map to ESPER, and let the operating system essentially move stuff from disk to RAM as it is touched. To make things efficient, data encoded essentially in a column-oriented structure. Used weak references to know when a given page file is no longer in use and can be deleted.
Project 2: