Make mmap mode more reliable by forcing GC at the correct spot
commit20f2172d133658905d318c36562172901bdd7854
authorShawn O. Pearce <spearce@spearce.org>
Thu, 25 Dec 2008 02:11:06 +0000 (24 18:11 -0800)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Sun, 4 Jan 2009 00:01:54 +0000 (4 01:01 +0100)
tree0c7d36de2858767087c3d30a034b859b3cd7f55f
parent71138b487a90ab1c156854426b38a1deeb42a709
Make mmap mode more reliable by forcing GC at the correct spot

ObjectLoaders can defer the bulk of their data access to the
getCachedBytes() method invocation, rather than at the time
of their construction.  That means there's code paths into
the mmap allocator which aren't protected by the "try GC and
try again" within openObject, resulting in some random crashes
due to mmap failures.

The right place to check for mmap failure and retry is within
WindowedFile.loadWindow, where we actually invoke the mmap call.
If the call fails, we need can immediately retry it, and if it
fails again, we can temporarily degrade to the byte[] variant
until the JVM is able to evict and GC enough space.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
org.spearce.jgit/src/org/spearce/jgit/lib/WindowedFile.java