public String stats() { StringBuilder b = new StringBuilder(); int n = 0; int size = 0; int alloc = 0; b.append("Segments: ").append(segments.length).append("\n"); for (Segment<T,A> seg : segments) { int ssize = 0; int salloc = 0; seg.lock(); try { ssize = seg.count(); salloc = seg.entryTable.length; } finally { seg.unlock(); } size += ssize; alloc += salloc; b.append("seg[").append(n++).append("]: size: ").append(ssize) .append(" alloc: ").append(salloc).append("\n"); } b.append("Total: size: ").append(size) .append(" alloc: ").append(alloc).append("\n"); return b.toString(); }
private void expunge() { Entry<T>[] table = entryTable; ReferenceQueue<Object> queue = referenceQueue; EntryRef ref; // note that we'll potentially see the refs for both the java object and // proxy -- whichever we see first will cause the entry to be removed; // the other will not match an entry and will be ignored. while ((ref = (EntryRef)queue.poll()) != null) { int hash; for (Entry<T> e = table[(hash = ref.hash()) & (table.length - 1)]; e != null; e = e.next) { if (hash == e.hash && (ref == e.objectRef || ref == e.proxyRef)) { remove(table, hash, e); break; } } } }
public void run() { for ( ;; ) { try { sleep(VULTURE_RUN_FREQ_SECONDS * 1000); } catch (InterruptedException e) {} boolean dump = size() > 200; if (dump) { LOG.debug("***Vulture {} waking, stats:", id); LOG.debug(stats()); } for (int i = segments.length; --i >= 0; ) { Segment<T,A> seg = segments[i]; seg.lock(); try { seg.expunge(); } finally { seg.unlock(); } yield(); } if (dump) { LOG.debug("***Vulture {} sleeping, stats:", id); LOG.debug(stats()); } } } };
public void run() { for ( ;; ) { try { sleep(VULTURE_RUN_FREQ_SECONDS * 1000); } catch (InterruptedException e) {} boolean dump = size() > 200; if (dump) { LOG.debug("***Vulture {} waking, stats:", id); LOG.debug(stats()); } for (int i = segments.length; --i >= 0; ) { Segment<T,A> seg = segments[i]; seg.lock(); try { seg.expunge(); } finally { seg.unlock(); } yield(); } if (dump) { LOG.debug("***Vulture {} sleeping, stats:", id); LOG.debug(stats()); } } } };