Class MemoryLimitCalculator


  • public class MemoryLimitCalculator
    extends java.lang.Object
    Runtime.freeMemory() technology is used to calculate the memory limit by using the percentage of the current maximum available memory, which can be used with MemoryLimiter.
    See Also:
    MemoryLimiter
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static long calculate​(float percentage)
      Take the current JVM's maximum available memory as a percentage of the result as the limit.
      static long defaultLimit()
      By default, it takes 80% of the maximum available memory of the current JVM.
      static long maxAvailable()
      Get the maximum available memory of the current JVM.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MemoryLimitCalculator

        public MemoryLimitCalculator()
    • Method Detail

      • maxAvailable

        public static long maxAvailable()
        Get the maximum available memory of the current JVM.
        Returns:
        maximum available memory
      • calculate

        public static long calculate​(float percentage)
        Take the current JVM's maximum available memory as a percentage of the result as the limit.
        Parameters:
        percentage - percentage
        Returns:
        available memory
      • defaultLimit

        public static long defaultLimit()
        By default, it takes 80% of the maximum available memory of the current JVM.
        Returns:
        available memory