BufferRecyclers (Jackson-core 2.10.0 API)
Date: 2019-09-25

com.fasterxml.jackson.core.util

## Class BufferRecyclers

- java.lang.Object
- - com.fasterxml.jackson.core.util.BufferRecyclers

-     public class BufferRecyclers
      extends Object

  Helper entity used to control access to simple buffer recyling scheme used for some encoding, decoding tasks.
  Since:
    2.9.2
  See Also:
    `BufferRecycler`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static ThreadLocal<SoftReference<BufferRecycler>>` | `_recyclerRef` This `ThreadLocal` contains a `SoftReference` to a `BufferRecycler` used to provide a low-cost buffer recycling between reader and writer instances.
    `static String` | `SYSTEM_PROPERTY_TRACK_REUSABLE_BUFFERS` System property that is checked to see if recycled buffers (see `BufferRecycler`) should be tracked, for purpose of forcing release of all such buffers, typically during major classloading.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BufferRecyclers()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static BufferRecycler` | `getBufferRecycler()` Main accessor to call for accessing possibly recycled `BufferRecycler` instance.
    `static int` | `releaseBuffers()` Specialized method that will release all recycled `BufferRecycler` if (and only if) recycler tracking has been enabled (see `SYSTEM_PROPERTY_TRACK_REUSABLE_BUFFERS`).

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SYSTEM_PROPERTY_TRACK_REUSABLE_BUFFERS

          public static final String SYSTEM_PROPERTY_TRACK_REUSABLE_BUFFERS

      System property that is checked to see if recycled buffers (see `BufferRecycler`) should be tracked, for purpose of forcing release of all such buffers, typically during major classloading.
      Since:
        2.9.6
      See Also:
        Constant Field Values

    - #### _recyclerRef

          protected static final ThreadLocal<SoftReference<BufferRecycler>> _recyclerRef

      This `ThreadLocal` contains a `SoftReference` to a `BufferRecycler` used to provide a low-cost buffer recycling between reader and writer instances.

  - ### Constructor Detail

    - #### BufferRecyclers

          public BufferRecyclers()

  - ### Method Detail

    - #### getBufferRecycler

          public static BufferRecycler getBufferRecycler()

      Main accessor to call for accessing possibly recycled `BufferRecycler` instance.

    - #### releaseBuffers

          public static int releaseBuffers()

      Specialized method that will release all recycled `BufferRecycler` if (and only if) recycler tracking has been enabled (see `SYSTEM_PROPERTY_TRACK_REUSABLE_BUFFERS`). This method is usually called on shutdown of the container like Application Server to ensure that no references are reachable via `ThreadLocal`s as this may cause unintentional retention of sizable amounts of memory. It may also be called regularly if GC for some reason does not clear up `SoftReference`s aggressively enough.
      Returns:
        Number of buffers released, if tracking enabled (zero or more); -1 if tracking not enabled.
      Since:
        2.9.6

Copyright © 2008–2019 FasterXML. All rights reserved.