@Override
    public ResourceReference refer(Object context) {
        final Throwable referenceStack = new Throwable();
        synchronized (activeReferences) {
            if (activeReferences.isEmpty()) {
                throw new IllegalStateException("Object is already destroyed, no more new references may be created."
                        + " State={ " + currentState() + " }");
            }
            activeReferences.put(referenceStack, context);
        }
        log.log(Level.FINE, referenceStack, () ->
                getClass().getName() + "@" + System.identityHashCode(this) + ".refer(): state={ " + currentState() + " }");
        return new DebugResourceReference(this, referenceStack);
    }
Does reference counting by putting stacktraces in a map together with an optional context.
Intended only for debugging as it is slow.
Used if system property jdisc.debug.resources=stack

@author baldersheim
jdisc_core/src/main/java/com/yahoo/jdisc/refcount/DebugReferencesWithStack.java