Enum OutOfMemoryPolicy

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<OutOfMemoryPolicy>

    public enum OutOfMemoryPolicy
    extends java.lang.Enum<OutOfMemoryPolicy>
    Represents the action to take when it's not possible to allocate memory.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      FallbackToHeap
      If it's not possible to allocate a buffer from direct memory, fallback to allocate an unpooled buffer from JVM heap.
      ThrowException
      Throw regular OOM exception without taking addition actions.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static OutOfMemoryPolicy valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static OutOfMemoryPolicy[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • ThrowException

        public static final OutOfMemoryPolicy ThrowException
        Throw regular OOM exception without taking addition actions.
      • FallbackToHeap

        public static final OutOfMemoryPolicy FallbackToHeap
        If it's not possible to allocate a buffer from direct memory, fallback to allocate an unpooled buffer from JVM heap.

        This will help absorb memory allocation spikes because the heap allocations will naturally slow down the process and will result if full GC cleanup if the Heap itself is full.

    • Method Detail

      • values

        public static OutOfMemoryPolicy[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (OutOfMemoryPolicy c : OutOfMemoryPolicy.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static OutOfMemoryPolicy valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null