JreMemoryLeakPreventionListener (Apache Tomcat 11.0.21 API Documentation)
Description: declaration: package: org.apache.catalina.core, class: JreMemoryLeakPreventionListener

# Class JreMemoryLeakPreventionListener

java.lang.Object
org.apache.catalina.core.JreMemoryLeakPreventionListener

All Implemented Interfaces:
  `LifecycleListener`

public class JreMemoryLeakPreventionListener extends Object implements LifecycleListener
Provide a workaround for known places where the Java Runtime environment can cause a memory leak or lock files.

Memory leaks occur when JRE code uses the context class loader to load a singleton as this will cause a memory leak if a web application class loader happens to be the context class loader at the time. The work-around is to initialise these singletons when Tomcat's common class loader is the context class loader.

Locked files usually occur when a resource inside a JAR is accessed without first disabling Jar URL connection caching. The workaround is to disable this caching by default.

This listener must only be nested within `Server` elements.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JreMemoryLeakPreventionListener()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getClassesToInitialize()`
  `boolean`
  `getInitSeedGenerator()`
  `boolean`
  `isAppContextProtection()`
  `boolean`
  `isDriverManagerProtection()`
  `boolean`
  `isUrlCacheProtection()`
  `void`
  `lifecycleEvent(LifecycleEvent event)`
  Acknowledge the occurrence of the specified event.
  `void`
  `setAppContextProtection(boolean appContextProtection)`
  `void`
  `setClassesToInitialize(String classesToInitialize)`
  `void`
  `setDriverManagerProtection(boolean driverManagerProtection)`
  `void`
  `setInitSeedGenerator(boolean initSeedGenerator)`
  `void`
  `setUrlCacheProtection(boolean urlCacheProtection)`

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### JreMemoryLeakPreventionListener

    public JreMemoryLeakPreventionListener()

- ## Method Details

  - ### isAppContextProtection

    public boolean isAppContextProtection()

  - ### setAppContextProtection

    public void setAppContextProtection(boolean appContextProtection)

  - ### isUrlCacheProtection

    public boolean isUrlCacheProtection()

  - ### setUrlCacheProtection

    public void setUrlCacheProtection(boolean urlCacheProtection)

  - ### isDriverManagerProtection

    public boolean isDriverManagerProtection()

  - ### setDriverManagerProtection

    public void setDriverManagerProtection(boolean driverManagerProtection)

  - ### getClassesToInitialize

    public String getClassesToInitialize()

  - ### setClassesToInitialize

    public void setClassesToInitialize(String classesToInitialize)

  - ### getInitSeedGenerator

    public boolean getInitSeedGenerator()

  - ### setInitSeedGenerator

    public void setInitSeedGenerator(boolean initSeedGenerator)

  - ### lifecycleEvent

    public void lifecycleEvent(LifecycleEvent event)
    Description copied from interface: `LifecycleListener`
    Acknowledge the occurrence of the specified event.
    Specified by:
      `lifecycleEvent` in interface `LifecycleListener`
    Parameters:
      `event` - LifecycleEvent that has occurred