com.hazelcast.instance

## Class DefaultOutOfMemoryHandler

- java.lang.Object
- - com.hazelcast.core.OutOfMemoryHandler
  - - com.hazelcast.instance.DefaultOutOfMemoryHandler

- Direct Known Subclasses:
    ClientOutOfMemoryHandler

      @PrivateApi
      public class DefaultOutOfMemoryHandler
      extends OutOfMemoryHandler

  Default OutOfMemoryHandler implementation that tries to release local resources (threads, connections, memory) immediately and disconnects members from the rest of the cluster.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `FREE_MAX_PERCENTAGE_PROP`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultOutOfMemoryHandler()`
    `DefaultOutOfMemoryHandler(double freeVersusMaxRatio)`
    `DefaultOutOfMemoryHandler(double freeVersusMaxRatio, MemoryInfoAccessor memoryInfoAccessor)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `onOutOfMemory(OutOfMemoryError oome, HazelcastInstance[] hazelcastInstances)` When an `OutOfMemoryError` is caught by Hazelcast threads, this method is called for ALL `HazelcastInstance`s knows by current JVM (actually ClassLoader).
    `boolean` | `shouldHandle(OutOfMemoryError oome)` Decides if the OutOfMemoryError thrown will be handled by this OutOfMemoryHandler or not.

    - ### Methods inherited from class com.hazelcast.core.OutOfMemoryHandler

      `tryCloseConnections, tryShutdown`

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

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

- - ### Field Detail

    - #### FREE_MAX_PERCENTAGE_PROP

          public static final String FREE_MAX_PERCENTAGE_PROP

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### DefaultOutOfMemoryHandler

          public DefaultOutOfMemoryHandler()

    - #### DefaultOutOfMemoryHandler

          public DefaultOutOfMemoryHandler(double freeVersusMaxRatio)

    - #### DefaultOutOfMemoryHandler

          public DefaultOutOfMemoryHandler(double freeVersusMaxRatio,
                                           MemoryInfoAccessor memoryInfoAccessor)

  - ### Method Detail

    - #### onOutOfMemory

          public void onOutOfMemory(OutOfMemoryError oome,
                                    HazelcastInstance[] hazelcastInstances)

      Description copied from class: `OutOfMemoryHandler`
      When an `OutOfMemoryError` is caught by Hazelcast threads, this method is called for ALL `HazelcastInstance`s knows by current JVM (actually ClassLoader).

      User can shutdown the `HazelcastInstance`, call `System.exit()`, just log the error, etc. The default handler tries to close socket connections to other nodes and shutdown the `HazelcastInstance`.

      Warning: `OutOfMemoryHandler` may not be called even if JVM throws `OutOfMemoryError` because the error may be thrown from an external (user) thread and Hazelcast may not be informed about `OutOfMemoryError`.

      Specified by:
        `onOutOfMemory` in class `OutOfMemoryHandler`
      Parameters:
        `oome` - OutOfMemoryError thrown by JVM
        `hazelcastInstances` - All HazelcastInstances known by JVM, can include inactive or NULL instances.
      See Also:
        `OutOfMemoryHandler.tryCloseConnections(HazelcastInstance)`, `OutOfMemoryHandler.tryShutdown(HazelcastInstance)`

    - #### shouldHandle

          public boolean shouldHandle(OutOfMemoryError oome)

      Description copied from class: `OutOfMemoryHandler`
      Decides if the OutOfMemoryError thrown will be handled by this OutOfMemoryHandler or not. If `true` is return, `OutOfMemoryHandler.onOutOfMemory(OutOfMemoryError, HazelcastInstance[])` will be called to handle error, otherwise OutOfMemoryError will be ignored.
      Overrides:
        `shouldHandle` in class `OutOfMemoryHandler`
      Parameters:
        `oome` - OutOfMemoryError thrown by JVM
      Returns:
        true if OutOfMemoryError will be handled, false otherwise

Copyright © 2018. All rights reserved.