summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorIgor Fedorenko <igor@ifedorenko.com>2010-01-06 21:18:44 -0500
committerShawn O. Pearce <spearce@spearce.org>2010-01-06 18:28:43 -0800
commit7085c0e4acb70b7d4a07e99d7a9bea3554d0fc62 (patch)
tree4c05f057640091ee82d7da3842b8533335b30b1d /org.eclipse.jgit
parentb427e32c188ecdfed1b0eb75785cb387b13eae26 (diff)
downloadjgit-7085c0e4acb70b7d4a07e99d7a9bea3554d0fc62.tar.gz
jgit-7085c0e4acb70b7d4a07e99d7a9bea3554d0fc62.zip
Explicitly release resources used by java.util.zip.Deflater
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>
Diffstat (limited to 'org.eclipse.jgit')
-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 60e85eb57f..b75328330f 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)