At least JDK 1.4 and 1.5 versions can hit an IOException if memory cannot be mapped. A workaround is to catch the exception and retry once. Signed-off-by: Robin Rosenberg <robin.rosenberg@xxxxxxxxxx> --- .../src/org/spearce/jgit/lib/Repository.java | 19 ++++++++++++++++--- 1 files changed, 16 insertions(+), 3 deletions(-) diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java index c9e8a2d..5e0e89a 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java @@ -145,9 +145,22 @@ public class Repository { return ol; } catch (IOException ioe) { // This shouldn't happen unless the pack was corrupted - // after we opened it. We'll ignore the error as though - // the object does not exist in this pack. - // + // after we opened it or the VM runs out of memory. This is + // a know problem with memory mapped I/O in java and have + // been noticed with JDK < 1.6. Tell the gc that now is a good + // time to collect and try once more. + try { + System.gc(); + final ObjectLoader ol = packs[k].get(id, tmp); + if (ol != null) + return ol; + } catch (IOException ioe2) { + ioe2.printStackTrace(); + ioe.printStackTrace(); + // Still fails.. that's BAD, maybe the pack has + // been corrupted after all, or the gc didn't manage + // to release enough previously mmaped areas. + } } } while (k > 0); } - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html