SOLR-7971: Reduce memory allocated by JavaBinCodec to encode large strings by an amount equal to the string.length()

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1697726 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2015-08-25 16:32:47 +00:00
parent d5d058df69
commit 2330786c5a
2 changed files with 5 additions and 1 deletions

View File

@ -168,6 +168,10 @@ Optimizations
are more efficient especially when cluster has a mix of collections in stateFormat=1
and stateFormat=2. (Scott Blum, shalin)
* SOLR-7971: Reduce memory allocated by JavaBinCodec to encode large strings by an amount
equal to the string.length().
(yonik, Steve Rowe, shalin)
Other Changes
----------------------

View File

@ -614,7 +614,7 @@ public class JavaBinCodec {
return;
}
int end = s.length();
int maxSize = end * 4;
int maxSize = end * 3; // 3 is enough, see SOLR-7971
if (bytes == null || bytes.length < maxSize) bytes = new byte[maxSize];
int sz = ByteUtils.UTF16toUTF8(s, 0, end, bytes, 0);