Search in sources :

Example 1 with RefCountChangeInfo

use of org.apache.geode.internal.offheap.RefCountChangeInfo in project geode by apache.

the class OffHeapTestUtil method checkOrphans.

public static void checkOrphans() {
    MemoryAllocatorImpl allocator = null;
    try {
        allocator = MemoryAllocatorImpl.getAllocator();
    } catch (CacheClosedException ignore) {
        // no off-heap memory so no orphans
        return;
    }
    long end = System.currentTimeMillis() + 5000;
    List<MemoryBlock> orphans = allocator.getOrphans();
    // Wait for the orphans to go away
    while (orphans != null && !orphans.isEmpty() && System.currentTimeMillis() < end) {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        orphans = allocator.getOrphans();
    }
    if (orphans != null && !orphans.isEmpty()) {
        List<RefCountChangeInfo> info = ReferenceCountHelper.getRefCountInfo(orphans.get(0).getAddress());
        System.out.println("FOUND ORPHAN!!");
        System.out.println("Sample orphan: " + orphans.get(0));
        System.out.println("Orphan info: " + info);
    }
    assertEquals(Collections.emptyList(), orphans);
}
Also used : MemoryBlock(org.apache.geode.internal.offheap.MemoryBlock) MemoryAllocatorImpl(org.apache.geode.internal.offheap.MemoryAllocatorImpl) CacheClosedException(org.apache.geode.cache.CacheClosedException) RefCountChangeInfo(org.apache.geode.internal.offheap.RefCountChangeInfo)

Aggregations

CacheClosedException (org.apache.geode.cache.CacheClosedException)1 MemoryAllocatorImpl (org.apache.geode.internal.offheap.MemoryAllocatorImpl)1 MemoryBlock (org.apache.geode.internal.offheap.MemoryBlock)1 RefCountChangeInfo (org.apache.geode.internal.offheap.RefCountChangeInfo)1