Index: lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java
===================================================================
--- lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java	(revision 1365558)
+++ 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;
@@ -72,6 +74,7 @@
    */
   HashSet<String> avoidCodecs;
 
+  static final long RAM_LEAK_THRESHOLD = 10 * 1024 * 1024;
 
   @Override
   protected void before() throws Exception {
@@ -272,6 +275,11 @@
     InfoStream.setDefault(savedInfoStream);
     if (savedLocale != null) Locale.setDefault(savedLocale);
     if (savedTimeZone != null) TimeZone.setDefault(savedTimeZone);
+    long ramEnd = estimateStaticRAM(RandomizedContext.current().getTargetClass());
+    if (ramEnd > 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 + " bytes.");
+    }
   }
 
   /**
@@ -280,4 +288,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;
+  }
 }
