/** * Signals the OutOfMemoryErrorDispatcher that an OutOfMemoryError happened. * <p/> * If there are any registered instances, they are automatically unregistered. This is done to prevent creating * new objects during the deregistration process while the system is suffering from a shortage of memory. * * @param outOfMemoryError the out of memory error */ public static void onOutOfMemory(OutOfMemoryError outOfMemoryError) { isNotNull(outOfMemoryError, "outOfMemoryError"); OUT_OF_MEMORY_ERROR_COUNT.incrementAndGet(); OutOfMemoryHandler h = clientHandler; if (h != null && h.shouldHandle(outOfMemoryError)) { try { HazelcastInstance[] clients = removeRegisteredClients(); h.onOutOfMemory(outOfMemoryError, clients); } catch (Throwable ignored) { ignore(ignored); } } h = handler; if (h != null && h.shouldHandle(outOfMemoryError)) { try { HazelcastInstance[] instances = removeRegisteredServers(); h.onOutOfMemory(outOfMemoryError, instances); } catch (Throwable ignored) { ignore(ignored); } } }
/** * Signals the OutOfMemoryErrorDispatcher that an OutOfMemoryError happened. * <p/> * If there are any registered instances, they are automatically unregistered. This is done to prevent creating * new objects during the deregistration process while the system is suffering from a shortage of memory. * * @param outOfMemoryError the out of memory error */ public static void onOutOfMemory(OutOfMemoryError outOfMemoryError) { isNotNull(outOfMemoryError, "outOfMemoryError"); OUT_OF_MEMORY_ERROR_COUNT.incrementAndGet(); OutOfMemoryHandler h = clientHandler; if (h != null && h.shouldHandle(outOfMemoryError)) { try { HazelcastInstance[] clients = removeRegisteredClients(); h.onOutOfMemory(outOfMemoryError, clients); } catch (Throwable ignored) { ignore(ignored); } } h = handler; if (h != null && h.shouldHandle(outOfMemoryError)) { try { HazelcastInstance[] instances = removeRegisteredServers(); h.onOutOfMemory(outOfMemoryError, instances); } catch (Throwable ignored) { ignore(ignored); } } }