Index: lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java	(revision 1365256)
+++ lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java	(working copy)
@@ -17,6 +17,8 @@
  * limitations under the License.
  */
 
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.HashMap;
@@ -71,8 +73,10 @@
    * @see SuppressCodecs
    */
   HashSet<String> avoidCodecs;
+  
+  static final long RAM_LEAK_THRESHOLD = 10 * 1024 * 1024;
+  long ramStart;
 
-
   @Override
   protected void before() throws Exception {
     // enable this by default, for IDE consistency with ant tests (as its the default from ant)
@@ -228,6 +232,7 @@
           Arrays.toString(avoidCodecs.toArray()));
       throw e;
     }
+    ramStart = estimateStaticRAM(targetClass);
   }
 
   /**
@@ -272,6 +277,11 @@
     InfoStream.setDefault(savedInfoStream);
     if (savedLocale != null) Locale.setDefault(savedLocale);
     if (savedTimeZone != null) TimeZone.setDefault(savedTimeZone);
+    long ramEnd = estimateStaticRAM(RandomizedContext.current().getTargetClass());
+    if (ramEnd - ramStart > RAM_LEAK_THRESHOLD) {
+      throw new RuntimeException("Please fix the static leaks in your test in a @AfterClass, "
+          + "your test seems to hang on to approximately " + (ramEnd - ramStart) + " bytes.");
+    }
   }
 
   /**
@@ -280,4 +290,16 @@
   private boolean shouldAvoidCodec(String codec) {
     return !avoidCodecs.isEmpty() && avoidCodecs.contains(codec);
   }
+  
+  private static long estimateStaticRAM(Class<?> clazz) throws Exception {
+    long sum = 0;
+    Field[] fields = clazz.getDeclaredFields();
+    for (Field field : fields) {
+      if (Modifier.isStatic(field.getModifiers())) {
+        field.setAccessible(true);
+        sum += RamUsageEstimator.sizeOf(field.get(null));
+      }
+    }
+    return sum;
+  }
 }
