Class MemoryLimitCalculator

java.lang.Object
org.apache.dubbo.common.threadpool.MemoryLimitCalculator

public class MemoryLimitCalculator extends 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:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    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
    By default, it takes 80% of the maximum available memory of the current JVM.
    static long
    Get the maximum available memory of the current JVM.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MemoryLimitCalculator

      public MemoryLimitCalculator()
  • Method Details

    • 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