예제 #1
0
  @Test(timeout = 60 * 1000)
  public void testReferenceCountingLoadTestOfDeath() throws InterruptedException {
    assertEquals(
        "should be no objects for collection", 0, JNIReference.getMgr().getNumPinnedObjects());
    RefCountedTester obj = RefCountedTester.make();
    for (int i = 0; i < 1000; i++) {
      RefCountedTester copy = obj.copyReference();
      assertNotNull("could not copy reference", copy);
    }
    obj = null;

    // Force a java collection
    while (JNIReference.getMgr().getNumPinnedObjects() > 0)
      MemoryTestHelper.forceJavaHeapWeakReferenceClear();

    assertEquals("Looks like we leaked an object", 0, JNIReference.getMgr().getNumPinnedObjects());
  }