Index: src/java/org/apache/lucene/analysis/PorterStemmer.java
===================================================================
--- src/java/org/apache/lucene/analysis/PorterStemmer.java	(revision 901845)
+++ src/java/org/apache/lucene/analysis/PorterStemmer.java	(working copy)
@@ -44,8 +44,13 @@
 */
 
 
-import java.io.*;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.FileInputStream;
 
+import static org.apache.lucene.util.RamUsageEstimator.NUM_BYTES_CHAR;
+import org.apache.lucene.util.ArrayUtil;
+
 /**
  *
  * Stemmer, implementing the Porter Stemming Algorithm
@@ -61,11 +66,11 @@
   private int i,    /* offset into b */
     j, k, k0;
   private boolean dirty = false;
-  private static final int INC = 50; /* unit of size whereby b is increased */
+  private static final int INITIAL_SIZE = 50;
   private static final int EXTRA = 1;
 
   public PorterStemmer() {
-    b = new char[INC];
+    b = new char[INITIAL_SIZE];
     i = 0;
   }
 
@@ -82,7 +87,7 @@
    */
   public void add(char ch) {
     if (b.length <= i + EXTRA) {
-      char[] new_b = new char[b.length+INC];
+      char[] new_b = new char[ArrayUtil.oversize(b.length+EXTRA, NUM_BYTES_CHAR)];
       System.arraycopy(b, 0, new_b, 0, b.length);
       b = new_b;
     }
@@ -451,7 +456,7 @@
   public boolean stem(char[] wordBuffer, int offset, int wordLen) {
     reset();
     if (b.length < wordLen) {
-      char[] new_b = new char[wordLen + EXTRA];
+      char[] new_b = new char[ArrayUtil.oversize(wordLen, NUM_BYTES_CHAR)];
       b = new_b;
     }
     System.arraycopy(wordBuffer, offset, b, 0, wordLen);
Index: src/java/org/apache/lucene/analysis/standard/StandardTokenizerImpl.java
===================================================================
--- src/java/org/apache/lucene/analysis/standard/StandardTokenizerImpl.java	(revision 901845)
+++ src/java/org/apache/lucene/analysis/standard/StandardTokenizerImpl.java	(working copy)
@@ -33,8 +33,11 @@
 
 import org.apache.lucene.analysis.Token;
 import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import static org.apache.lucene.util.RamUsageEstimator.NUM_BYTES_CHAR;
+import org.apache.lucene.util.ArrayUtil;
 
 
+
 /**
  * This class is a scanner generated by 
  * <a href="http://www.jflex.de/">JFlex</a> 1.4.1
@@ -444,7 +447,8 @@
     /* is the buffer big enough? */
     if (zzCurrentPos >= zzBuffer.length) {
       /* if not: blow it up */
-      char newBuffer[] = new char[zzCurrentPos*2];
+      char newBuffer[] = new char[ArrayUtil.oversize(zzBuffer.length, NUM_BYTES_CHAR)];
+
       System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
       zzBuffer = newBuffer;
     }
Index: src/java/org/apache/lucene/index/ByteBlockPool.java
===================================================================
--- src/java/org/apache/lucene/index/ByteBlockPool.java	(revision 901845)
+++ src/java/org/apache/lucene/index/ByteBlockPool.java	(working copy)
@@ -34,7 +34,10 @@
  * hit a non-zero byte. */
 
 import java.util.Arrays;
+import static org.apache.lucene.util.RamUsageEstimator.NUM_BYTES_OBJECT_REF;
+import org.apache.lucene.util.ArrayUtil;
 
+
 final class ByteBlockPool {
 
   abstract static class Allocator {
@@ -83,7 +86,8 @@
 
   public void nextBuffer() {
     if (1+bufferUpto == buffers.length) {
-      byte[][] newBuffers = new byte[(int) (buffers.length*1.5)][];
+      byte[][] newBuffers = new byte[ArrayUtil.oversize(buffers.length+1,
+                                                        NUM_BYTES_OBJECT_REF)][];
       System.arraycopy(buffers, 0, newBuffers, 0, buffers.length);
       buffers = newBuffers;
     }
Index: src/java/org/apache/lucene/index/CharBlockPool.java
===================================================================
--- src/java/org/apache/lucene/index/CharBlockPool.java	(revision 901845)
+++ src/java/org/apache/lucene/index/CharBlockPool.java	(working copy)
@@ -17,6 +17,9 @@
  * limitations under the License.
  */
 
+import static org.apache.lucene.util.RamUsageEstimator.NUM_BYTES_OBJECT_REF;
+import org.apache.lucene.util.ArrayUtil;
+
 final class CharBlockPool {
 
   public char[][] buffers = new char[10][];
@@ -42,7 +45,8 @@
 
   public void nextBuffer() {
     if (1+bufferUpto == buffers.length) {
-      char[][] newBuffers = new char[(int) (buffers.length*1.5)][];
+      char[][] newBuffers = new char[ArrayUtil.oversize(buffers.length+1,
+                                                        NUM_BYTES_OBJECT_REF)][];
       System.arraycopy(buffers, 0, newBuffers, 0, buffers.length);
       buffers = newBuffers;
     }
Index: src/java/org/apache/lucene/index/MultipleTermPositions.java
===================================================================
--- src/java/org/apache/lucene/index/MultipleTermPositions.java	(revision 901845)
+++ src/java/org/apache/lucene/index/MultipleTermPositions.java	(working copy)
@@ -17,14 +17,15 @@
  * limitations under the License.
  */
 
-import org.apache.lucene.util.PriorityQueue;
-
 import java.io.IOException;
 import java.util.Arrays;
-
 import java.util.LinkedList;
 import java.util.List;
 
+import org.apache.lucene.util.PriorityQueue;
+import static org.apache.lucene.util.RamUsageEstimator.NUM_BYTES_INT;
+import org.apache.lucene.util.ArrayUtil;
+
 /**
  * Allows you to iterate over the {@link TermPositions} for multiple {@link Term}s as
  * a single {@link TermPositions}.
@@ -83,10 +84,10 @@
     }
 
     private void growArray() {
-      int[] newArray = new int[_arraySize * 2];
+      int[] newArray = new int[ArrayUtil.oversize(_arraySize+1, NUM_BYTES_INT)];
       System.arraycopy(_array, 0, newArray, 0, _arraySize);
       _array = newArray;
-      _arraySize *= 2;
+      _arraySize = _array.length;
     }
   }
 
Index: src/java/org/apache/lucene/index/TermInfosWriter.java
===================================================================
--- src/java/org/apache/lucene/index/TermInfosWriter.java	(revision 901845)
+++ src/java/org/apache/lucene/index/TermInfosWriter.java	(working copy)
@@ -22,7 +22,9 @@
 import org.apache.lucene.store.IndexOutput;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.UnicodeUtil;
+import org.apache.lucene.util.ArrayUtil;
 
+
 /** This stores a monotonically increasing set of <Term, TermInfo> pairs in a
   Directory.  A TermInfos can be written once, in order.  */
 
@@ -207,7 +209,7 @@
     output.writeBytes(termBytes, start, length);  // write delta bytes
     output.writeVInt(fieldNumber); // write field num
     if (lastTermBytes.length < termBytesLength) {
-      byte[] newArray = new byte[(int) (termBytesLength*1.5)];
+      byte[] newArray = new byte[ArrayUtil.oversize(termBytesLength, 1)];
       System.arraycopy(lastTermBytes, 0, newArray, 0, start);
       lastTermBytes = newArray;
     }
Index: src/java/org/apache/lucene/index/TermVectorsReader.java
===================================================================
--- src/java/org/apache/lucene/index/TermVectorsReader.java	(revision 901845)
+++ src/java/org/apache/lucene/index/TermVectorsReader.java	(working copy)
@@ -20,6 +20,8 @@
 import org.apache.lucene.store.BufferedIndexInput;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.util.ArrayUtil;
+import static org.apache.lucene.util.RamUsageEstimator.NUM_BYTES_CHAR;
 
 import java.io.IOException;
 import java.util.Arrays;
@@ -460,7 +462,7 @@
       if (preUTF8) {
         // Term stored as java chars
         if (charBuffer.length < totalLength) {
-          char[] newCharBuffer = new char[(int) (1.5*totalLength)];
+          char[] newCharBuffer = new char[ArrayUtil.oversize(totalLength, NUM_BYTES_CHAR)];
           System.arraycopy(charBuffer, 0, newCharBuffer, 0, start);
           charBuffer = newCharBuffer;
         }
@@ -469,7 +471,7 @@
       } else {
         // Term stored as utf8 bytes
         if (byteBuffer.length < totalLength) {
-          byte[] newByteBuffer = new byte[(int) (1.5*totalLength)];
+          byte[] newByteBuffer = new byte[ArrayUtil.oversize(totalLength, 1)];
           System.arraycopy(byteBuffer, 0, newByteBuffer, 0, start);
           byteBuffer = newByteBuffer;
         }
Index: src/java/org/apache/lucene/store/IndexInput.java
===================================================================
--- src/java/org/apache/lucene/store/IndexInput.java	(revision 901845)
+++ src/java/org/apache/lucene/store/IndexInput.java	(working copy)
@@ -22,6 +22,8 @@
 import java.util.Map;
 import java.util.HashMap;
 
+import org.apache.lucene.util.ArrayUtil;
+
 /** Abstract base class for input from a file in a {@link Directory}.  A
  * random-access input stream.  Used for all Lucene index input operations.
  * @see Directory
@@ -122,16 +124,18 @@
     if (preUTF8Strings)
       return readModifiedUTF8String();
     int length = readVInt();
-    if (bytes == null || length > bytes.length)
-      bytes = new byte[(int) (length*1.25)];
+    if (bytes == null || length > bytes.length) {
+      bytes = new byte[ArrayUtil.oversize(length, 1)];
+    }
     readBytes(bytes, 0, length);
     return new String(bytes, 0, length, "UTF-8");
   }
 
   private String readModifiedUTF8String() throws IOException {
     int length = readVInt();
-    if (chars == null || length > chars.length)
+    if (chars == null || length > chars.length) {
       chars = new char[length];
+    }
     readChars(chars, 0, length);
     return new String(chars, 0, length);
   }
@@ -157,10 +161,11 @@
       else if ((b & 0xE0) != 0xE0) {
 	buffer[i] = (char)(((b & 0x1F) << 6)
 		 | (readByte() & 0x3F));
-      } else
+      } else {
 	buffer[i] = (char)(((b & 0x0F) << 12)
 		| ((readByte() & 0x3F) << 6)
 	        |  (readByte() & 0x3F));
+      }
     }
   }
 
@@ -181,10 +186,9 @@
       byte b = readByte();
       if ((b & 0x80) == 0){
         //do nothing, we only need one byte
-      }
-      else if ((b & 0xE0) != 0xE0) {
+      } else if ((b & 0xE0) != 0xE0) {
         readByte();//read an additional byte
-      } else{      
+      } else {      
         //read two additional bytes.
         readByte();
         readByte();
Index: src/java/org/apache/lucene/util/UnicodeUtil.java
===================================================================
--- src/java/org/apache/lucene/util/UnicodeUtil.java	(revision 901845)
+++ src/java/org/apache/lucene/util/UnicodeUtil.java	(working copy)
@@ -78,7 +78,7 @@
 
     public void setLength(int newLength) {
       if (result.length < newLength) {
-        byte[] newArray = new byte[(int) (1.5*newLength)];
+        byte[] newArray = new byte[ArrayUtil.oversize(newLength, 1)];
         System.arraycopy(result, 0, newArray, 0, length);
         result = newArray;
       }
@@ -93,7 +93,7 @@
 
     public void setLength(int newLength) {
       if (result.length < newLength) {
-        char[] newArray = new char[(int) (1.5*newLength)];
+        char[] newArray = new char[ArrayUtil.oversize(newLength, RamUsageEstimator.NUM_BYTES_CHAR)];
         System.arraycopy(result, 0, newArray, 0, length);
         result = newArray;
       }
@@ -120,7 +120,7 @@
       final int code = (int) source[i++];
 
       if (upto+4 > out.length) {
-        byte[] newOut = new byte[2*out.length];
+        byte[] newOut = new byte[ArrayUtil.oversize(upto+4, 1)];
         assert newOut.length >= upto+4;
         System.arraycopy(out, 0, newOut, 0, upto);
         result.result = out = newOut;
@@ -179,7 +179,7 @@
       final int code = (int) source[i++];
 
       if (upto+4 > out.length) {
-        byte[] newOut = new byte[2*out.length];
+        byte[] newOut = new byte[ArrayUtil.oversize(upto+4, 1)];
         assert newOut.length >= upto+4;
         System.arraycopy(out, 0, newOut, 0, upto);
         result.result = out = newOut;
@@ -233,7 +233,7 @@
       final int code = (int) s.charAt(i);
 
       if (upto+4 > out.length) {
-        byte[] newOut = new byte[2*out.length];
+        byte[] newOut = new byte[ArrayUtil.oversize(upto+4, 1)];
         assert newOut.length >= upto+4;
         System.arraycopy(out, 0, newOut, 0, upto);
         result.result = out = newOut;
@@ -283,9 +283,9 @@
     final int end = offset + length;
     char[] out = result.result;
     if (result.offsets.length <= end) {
-      int[] newOffsets = new int[2*end];
+      int[] newOffsets = new int[ArrayUtil.oversize(end, RamUsageEstimator.NUM_BYTES_INT)];
       System.arraycopy(result.offsets, 0, newOffsets, 0, result.offsets.length);
-      result.offsets  = newOffsets;
+      result.offsets = newOffsets;
     }
     final int[] offsets = result.offsets;
 
Index: src/java/org/apache/lucene/util/SortedVIntList.java
===================================================================
--- src/java/org/apache/lucene/util/SortedVIntList.java	(revision 901845)
+++ src/java/org/apache/lucene/util/SortedVIntList.java	(working copy)
@@ -128,8 +128,8 @@
       }
   
       if ((lastBytePos + MAX_BYTES_PER_INT) > bytes.length) {
-        // biggest possible int does not fit
-        resizeBytes((bytes.length * 2) + MAX_BYTES_PER_INT);
+        // Biggest possible int does not fit.
+        resizeBytes(ArrayUtil.oversize(bytes.length + MAX_BYTES_PER_INT, 1));
       }
   
       // See org.apache.lucene.store.IndexOutput.writeVInt()
Index: src/test/org/apache/lucene/util/TestSortedVIntList.java
===================================================================
--- src/test/org/apache/lucene/util/TestSortedVIntList.java	(revision 901845)
+++ src/test/org/apache/lucene/util/TestSortedVIntList.java	(working copy)
@@ -193,4 +193,15 @@
   public void test12() {
    tstIllegalArgExc(new int[] {0,1,1,2,3,5,8,0});
   }
+  public void test13Allocation() {
+    int [] a = new int[2000]; // SortedVIntList initial byte size is 128
+    for (int i = 0; i < a.length; i++) {
+      a[i] = (107 + i) * i;
+    }
+    try {
+      tstIterator(new SortedVIntList(a), a);
+    } catch (IOException ioe) {
+      throw new Error(ioe);
+    }
+  }
 }
