Index: src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEdit.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEdit.java (revision 1536958) +++ src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEdit.java (working copy) @@ -84,7 +84,7 @@ private static final String PREFIX_CLUSTER_KEY = "."; private final int VERSION_2 = -1; - private final ArrayList kvs = new ArrayList(); + private final ArrayList kvs = new ArrayList(1); /** * This variable contains the information of the column family replication settings and contains @@ -206,6 +206,7 @@ } public void readFields(DataInput in) throws IOException { + int oldSize = kvs.size(); kvs.clear(); scopes.clear(); Decoder decoder = this.codec.getDecoder((DataInputStream) in); @@ -217,6 +218,11 @@ length = in.readInt(); } + // reclaim excess space if we're reusing this WALEdit + if (oldSize > 100*length) { + kvs.trimToSize(); + kvs.ensureCapacity(length); + } // read in all the key values for(int i=0; i< length && decoder.advance(); i++) { kvs.add(decoder.current());