Index: src/java/org/apache/lucene/index/DocumentsWriter.java =================================================================== --- src/java/org/apache/lucene/index/DocumentsWriter.java (revision 610772) +++ src/java/org/apache/lucene/index/DocumentsWriter.java (working copy) @@ -2768,10 +2768,26 @@ public int byteOffset = -BYTE_BLOCK_SIZE; // Current head offset public void reset() { - recycleByteBlocks(buffers, 1+bufferUpto); - bufferUpto = -1; - byteUpto = BYTE_BLOCK_SIZE; - byteOffset = -BYTE_BLOCK_SIZE; + if (bufferUpto != -1) { + // We allocated at least one buffer + + for(int i=0;i 0) + // Recycle all but the first buffer + recycleByteBlocks(buffers, 1, 1+bufferUpto); + + // Re-use the first buffer + bufferUpto = 0; + byteUpto = 0; + byteOffset = 0; + buffer = buffers[0]; + } } public void nextBuffer() { @@ -2782,7 +2798,6 @@ buffers = newBuffers; } buffer = buffers[bufferUpto] = getByteBlock(); - Arrays.fill(buffer, (byte) 0); byteUpto = 0; byteOffset += BYTE_BLOCK_SIZE; @@ -2954,10 +2969,10 @@ } /* Return a byte[] to the pool */ - synchronized void recycleByteBlocks(byte[][] blocks, int numBlocks) { - for(int i=0;i