git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[EGIT PATCH 2/9] Catch mmap errors and retry.

From
Robin Rosenberg <robin.rosenberg@dewire.com>
Date
Feb 28, 2007, 22:26 UTC
Message-ID
<20070228222615.12021.4058.stgit@lathund.dewire.com>
In-Reply-To
<20070228222355.12021.13029.stgit@lathund.dewire.com>

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@dewire.com>
---
 .../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);
 		}
Previous: Robin RosenbergNext: Robin Rosenberg
Message 3 of 12 in “Misc minor fixes”
  1. 0/9 Misc minor fixesRobin Rosenberg, Feb 28, 2007
  2. 1/9 Minor fix.Robin Rosenberg, Feb 28, 2007
  3. 2/9 Catch mmap errors and retry.Robin Rosenberg, Feb 28, 2007
  4. 3/9 Use mmap per default.Robin Rosenberg, Feb 28, 2007
  5. 4/9 Add .qualifier to the plugin version.Robin Rosenberg, Feb 28, 2007
  6. 5/9 Force full checkpoint for CheckpointOperation.Robin Rosenberg, Feb 28, 2007
  7. 6/9 Add branch and StGit patch to decoratorRobin Rosenberg, Feb 28, 2007
  8. Shawn O. PearceMar 1, 2007
  9. Robin RosenbergMar 1, 2007
  10. 7/9 Support tag objectsRobin Rosenberg, Feb 28, 2007
  11. 8/9 Handle odd tag formats created by tools such as cvsimport.Robin Rosenberg, Feb 28, 2007
  12. 9/9 Performance test for jgit.Robin Rosenberg, Feb 28, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.