public static void main(String[] args) throws Exception {
    DistributedSystem system = DistributedSystem.connect(new java.util.Properties());
    Cache cache = CacheFactory.create(system);
    AttributesFactory factory = new AttributesFactory();

    factory.setEvictionAttributes(
        EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK));
    factory.setDiskSynchronous(true);
    factory.setDiskStoreName(cache.createDiskStoreFactory()
        .setDiskDirs(new java.io.File[] {new java.io.File(System.getProperty("user.dir"))})
        .create("TestHeapLRU").getName());
    Region region = cache.createRegion("TestDiskRegion", factory.create());

    Thread thread = new LoggingThread("Annoying thread", () -> {
      try {
        while (true) {
          System.out.println("Annoy...");
          Object[] array = new Object[10 /* * 1024 */];
          for (int i = 0; i < array.length; i++) {
            array[i] = new byte[1024];
            Thread.sleep(10);
          }

          System.out.println("SYSTEM GC");
          System.gc();
          Thread.sleep(1000);
        }

      } catch (InterruptedException ex) {
        System.err.println("Interrupted"); // FIXME should throw
      }
    });
    // thread.start();

    // ArrayList list = new ArrayList();
    for (int i = 0; i < Integer.MAX_VALUE; i++) {
      if (i % 1000 == 0) {
        // System.out.println("i = " + i);
        // list = new ArrayList();

      } else {
        // list.add(new Integer(i));
      }

      Integer key = i % 10000;
      long[] value = new long[2000];
      // System.out.println("Put " + key + " -> " + value);
      region.put(key, value);
    }
  }
Tests populating a region with data that is ever-increasing in size. It is used for testing the
"Heap LRU" feature that helps prevent out of memory errors.
geode-core/src/test/java/org/apache/geode/cache30/TestHeapLRU.java