summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorIgor Fedorenko2010-01-06 21:18:44 (EST)
committer Shawn O. Pearce2010-01-06 21:28:43 (EST)
commit7085c0e4acb70b7d4a07e99d7a9bea3554d0fc62 (patch)
tree4c05f057640091ee82d7da3842b8533335b30b1d
parentb427e32c188ecdfed1b0eb75785cb387b13eae26 (diff)
downloadjgit-7085c0e4acb70b7d4a07e99d7a9bea3554d0fc62.zip
jgit-7085c0e4acb70b7d4a07e99d7a9bea3554d0fc62.tar.gz
jgit-7085c0e4acb70b7d4a07e99d7a9bea3554d0fc62.tar.bz2
Explicitly release resources used by java.util.zip.Deflaterrefs/changes/84/184/2
Deflater can use significant amount of native (i.e. C) heap space. Failure to promptly release this memory results in native memory leak in some cases, particularly severe for VMs with large java max heap size. For example, running Team->Commit in one of my EGit workspaces results in ~500M java process size increase without any significant change to amount of used java heap when JVM is started with -Xmx1024m. Change-Id: I649679a8df5683ebedd9380d703513d31c625932 Signed-off-by: Igor Fedorenko <igor@ifedorenko.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectWriter.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectWriter.java
index 60e85eb..b753283 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectWriter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectWriter.java
@@ -78,8 +78,6 @@ public class ObjectWriter {
private final MessageDigest md;
- private final Deflater def;
-
/**
* Construct an Object writer for the specified repository
* @param d
@@ -88,7 +86,6 @@ public class ObjectWriter {
r = d;
buf = new byte[8192];
md = Constants.newMessageDigest();
- def = new Deflater(r.getConfig().getCore().getCompression());
}
/**
@@ -309,6 +306,7 @@ public class ObjectWriter {
final DeflaterOutputStream deflateStream;
final FileOutputStream fileStream;
ObjectId id = null;
+ Deflater def = null;
if (store) {
t = File.createTempFile("noz", null, r.getObjectsDirectory());
@@ -320,7 +318,7 @@ public class ObjectWriter {
md.reset();
if (store) {
- def.reset();
+ def = new Deflater(r.getConfig().getCore().getCompression());
deflateStream = new DeflaterOutputStream(fileStream, def);
} else
deflateStream = null;
@@ -374,6 +372,9 @@ public class ObjectWriter {
t.delete();
}
}
+ if (def != null) {
+ def.end();
+ }
}
if (t == null)