]> source.dussan.org Git - jgit.git/commitdiff
Expose disposeBody() on RevCommit and RevTag 85/47585/2
authorShawn Pearce <spearce@spearce.org>
Sun, 10 May 2015 17:42:09 +0000 (10:42 -0700)
committerShawn Pearce <spearce@spearce.org>
Sun, 10 May 2015 17:56:34 +0000 (10:56 -0700)
Applications that use a commit message once and do not
need it again can free the body to save memory. Expose
the disposeBody() methods to support this and use it in
pgm.Log which only visits each commit once.

Change-Id: I4142a0749c24f15386ee7fb119934a0432234de3

org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevTag.java

index 048526ee8a32b446b54b46f8d956bdafda330350..688de2c499ddd9b83653379cceac191adf355065 100644 (file)
@@ -267,6 +267,7 @@ class Log extends RevWalkTextBuiltin {
                        outw.print(s);
                        outw.println();
                }
+               c.disposeBody();
 
                outw.println();
                if (showNotes(c))
index 37f1d7b8dac07b808b9a26c8d022c73de99ba203..c23e4e3288daad250596e5309a72b8e3248ed483 100644 (file)
@@ -609,7 +609,19 @@ public class RevCommit extends RevObject {
                inDegree = 0;
        }
 
-       final void disposeBody() {
+       /**
+        * Discard the message buffer to reduce memory usage.
+        * <p>
+        * After discarding the memory usage of the {@code RevCommit} is reduced to
+        * only the {@link #getTree()} and {@link #getParents()} pointers and the
+        * time in {@link #getCommitTime()}. Accessing other properties such as
+        * {@link #getAuthorIdent()}, {@link #getCommitterIdent()} or either message
+        * function requires reloading the buffer by invoking
+        * {@link RevWalk#parseBody(RevObject)}.
+        *
+        * @since 4.0
+        */
+       public final void disposeBody() {
                buffer = null;
        }
 
index 75201164c1446a20ddf2754e1e763f03991fc137..bf2785e0d76803073dc4dda81ab34a6f290fe8e0 100644 (file)
@@ -270,7 +270,18 @@ public class RevTag extends RevObject {
                return tagName;
        }
 
-       final void disposeBody() {
+       /**
+        * Discard the message buffer to reduce memory usage.
+        * <p>
+        * After discarding the memory usage of the {@code RevTag} is reduced to
+        * only the {@link #getObject()} pointer and {@link #getTagName()}.
+        * Accessing other properties such as {@link #getTaggerIdent()} or either
+        * message function requires reloading the buffer by invoking
+        * {@link RevWalk#parseBody(RevObject)}.
+        *
+        * @since 4.0
+        */
+       public final void disposeBody() {
                buffer = null;
        }
 }