neo4j/neo4j — pull request #3100 by chrisvest (2014-09-18 19:52:33+00:00)
Title: Fix Muninn memory leak from pool PageCursors

The cursor freelists were anonymous inner classes of the MuninnPagedFile class,
and this meant that they were accidentally strongly referencing the Page
freelist.
This meant that if we made use of thread-local PageCursor pooling, the cursor
freelist would keep all pages alive that could be reached through the page
freelist. And the cursor freelists were kept alive by the cursors, who in turn
was kept alive by thread-local references.
This way, a potentially very large amount of pages could be kept live after the
page cache had been shut down, because threads that had accessed it were still
running.
This was especially a problem for unit tests, since they fork only a few JVMs,
have a main thread that runs all tests, and many tests start and stop database
instances, and thereby also starts and stops page caches.

The fix was to make the cursor freelist classes static, so they no longer hold
a reference to the page freelist. Further more, the page freelist is now also
nulled out when the cache shuts down, even though this isn't strictly
necessary for fixing this issue.