Class NamedMemoryLimiter


  • @ThreadSafe
    public final class NamedMemoryLimiter
    extends java.lang.Object
    A simple, thread-safe memory usage tracker, named to reflect a particular scope.
    • Constructor Detail

      • NamedMemoryLimiter

        public NamedMemoryLimiter​(long limitBytes,
                                  java.lang.String scope)
    • Method Detail

      • usageExceedsLimit

        public boolean usageExceedsLimit()
        Returns:
        true if the current number of bytes allocated against the tracker has breached the limit, false otherwise
      • increment

        public long increment​(long bytes)
      • decrement

        public long decrement​(long bytes)
      • currentBytesUsed

        public long currentBytesUsed()
      • limitBytes

        public long limitBytes()
      • setLimitBytes

        public void setLimitBytes​(long bytes)