On Thu, May 29, 2014 at 5:16 PM, <[email protected]> wrote: > Fixing a memory leak when large arguments are logged in request response logs. > > > Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo > Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/eed70bb6 > Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/eed70bb6 > Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/eed70bb6 > > Branch: refs/heads/console-v2 > Commit: eed70bb6fc12265a3cd1754dd35e12f612190faf > Parents: 4090977 > Author: Aaron McCurry <[email protected]> > Authored: Thu May 22 20:54:53 2014 -0400 > Committer: Aaron McCurry <[email protected]> > Committed: Thu May 22 20:54:53 2014 -0400 > > ---------------------------------------------------------------------- > .../java/org/apache/blur/utils/BlurUtil.java | 27 +++++++++++++++++--- > 1 file changed, 23 insertions(+), 4 deletions(-) > ---------------------------------------------------------------------- > > > http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/eed70bb6/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java > ---------------------------------------------------------------------- > diff --git a/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java > b/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java > index 9a3cf78..a6eda0f 100644 > --- a/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java > +++ b/blur-core/src/main/java/org/apache/blur/utils/BlurUtil.java > @@ -159,14 +159,30 @@ public class BlurUtil { > public static final Term PRIME_DOC_TERM = new > Term(BlurConstants.PRIME_DOC, BlurConstants.PRIME_DOC_VALUE); > > static class LoggerArgsState { > - public LoggerArgsState(int size) { > - _buffer = new ResetableTMemoryBuffer(size); > - _tjsonProtocol = new TJSONProtocol(_buffer); > - } > + > + private static final int MAX_BUFFER_SIZE = 16384; > + private static final int MAX_BUILDER_SIZE = 16384; > > TJSONProtocol _tjsonProtocol; > ResetableTMemoryBuffer _buffer; > StringBuilder _builder = new StringBuilder(); > + final int _size; > + > + LoggerArgsState(int size) { > + _size = size; > + _buffer = new ResetableTMemoryBuffer(_size); > + _tjsonProtocol = new TJSONProtocol(_buffer); > + } > + > + void reset() { > + if (_buffer.getArray().length >= MAX_BUFFER_SIZE) { > + _buffer = new ResetableTMemoryBuffer(_size); > + _tjsonProtocol = new TJSONProtocol(_buffer); > + } > + if (_builder.length() >= MAX_BUILDER_SIZE) {
did you mean _builder.capacity() there? --tim
