diff options
author | Shawn Pearce <spearce@spearce.org> | 2015-05-10 10:42:09 -0700 |
---|---|---|
committer | Shawn Pearce <spearce@spearce.org> | 2015-05-10 10:56:34 -0700 |
commit | e4e947049f60d72f766d90dff22b488cbe06ba95 (patch) | |
tree | 6dadaa4505c25ffea7dc9e87d0388590fb3c6b43 | |
parent | ca7daa5226d88c8533c2316e5bc8a66ea8a373c5 (diff) | |
download | jgit-e4e947049f60d72f766d90dff22b488cbe06ba95.tar.gz jgit-e4e947049f60d72f766d90dff22b488cbe06ba95.zip |
Expose disposeBody() on RevCommit and RevTag
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
3 files changed, 26 insertions, 2 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java index 048526ee8a..688de2c499 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Log.java @@ -267,6 +267,7 @@ class Log extends RevWalkTextBuiltin { outw.print(s); outw.println(); } + c.disposeBody(); outw.println(); if (showNotes(c)) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java index 37f1d7b8da..c23e4e3288 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java @@ -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; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevTag.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevTag.java index 75201164c1..bf2785e0d7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevTag.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevTag.java @@ -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; } } |