Enum PoolingPolicy

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

    public enum PoolingPolicy
    extends java.lang.Enum<PoolingPolicy>
    Define a policy for allocating buffers.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      PooledDirect
      Use Direct memory for all buffers and pool the memory.
      UnpooledHeap
      Allocate memory from JVM heap without any pooling.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static PoolingPolicy valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static PoolingPolicy[] 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

      • UnpooledHeap

        public static final PoolingPolicy UnpooledHeap
        Allocate memory from JVM heap without any pooling.

        This option has the least overhead in terms of memory usage since the memory will be automatically reclaimed by the JVM GC but might impose a performance penalty at high throughput.

      • PooledDirect

        public static final PoolingPolicy PooledDirect
        Use Direct memory for all buffers and pool the memory.

        Direct memory will avoid the overhead of JVM GC and most memory copies when reading and writing to socket channel.

        Pooling will add memory space overhead due to the fact that there will be fragmentation in the allocator and that threads will keep a portion of memory as thread-local to avoid contention when possible.

    • Method Detail

      • values

        public static PoolingPolicy[] 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 (PoolingPolicy c : PoolingPolicy.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static PoolingPolicy 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