JreMemoryLeakPreventionListener (Apache Tomcat 9.0.119 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()`
  Constructs a new JreMemoryLeakPreventionListener.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getClassesToInitialize()`
  Get the classes to initialize.
  `boolean`
  `getForkJoinCommonPoolProtection()`
  `boolean`
  `getInitSeedGenerator()`
  Get the init seed generator flag.
  `boolean`
  `isAppContextProtection()`
  Get the app context protection flag.
  `boolean`
  `isAWTThreadProtection()`
  `boolean`
  `isDriverManagerProtection()`
  Get the DriverManager protection flag.
  `boolean`
  `isGcDaemonProtection()`
  `boolean`
  `isLdapPoolProtection()`
  `boolean`
  `isTokenPollerProtection()`
  `boolean`
  `isUrlCacheProtection()`
  Get the URL cache protection flag.
  `boolean`
  `isXmlParsingProtection()`
  `void`
  `lifecycleEvent(LifecycleEvent event)`
  Acknowledge the occurrence of the specified event.
  `void`
  `setAppContextProtection(boolean appContextProtection)`
  Set the app context protection flag.
  `void`
  `setAWTThreadProtection(boolean awtThreadProtection)`
  `void`
  `setClassesToInitialize(String classesToInitialize)`
  Set the classes to initialize.
  `void`
  `setDriverManagerProtection(boolean driverManagerProtection)`
  Set the DriverManager protection flag.
  `void`
  `setForkJoinCommonPoolProtection(boolean forkJoinCommonPoolProtection)`
  `void`
  `setGcDaemonProtection(boolean gcDaemonProtection)`
  `void`
  `setInitSeedGenerator(boolean initSeedGenerator)`
  Set the init seed generator flag.
  `void`
  `setLdapPoolProtection(boolean ldapPoolProtection)`
  `void`
  `setTokenPollerProtection(boolean tokenPollerProtection)`
  `void`
  `setUrlCacheProtection(boolean urlCacheProtection)`
  Set the URL cache protection flag.
  `void`
  `setXmlParsingProtection(boolean xmlParsingProtection)`

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### JreMemoryLeakPreventionListener

    public JreMemoryLeakPreventionListener()
    Constructs a new JreMemoryLeakPreventionListener.

- ## Method Details

  - ### isAppContextProtection

    public boolean isAppContextProtection()
    Get the app context protection flag.
    Returns:
      the app context protection flag

  - ### setAppContextProtection

    public void setAppContextProtection(boolean appContextProtection)
    Set the app context protection flag.
    Parameters:
      `appContextProtection` - the flag to set

  - ### isAWTThreadProtection

    public boolean isAWTThreadProtection()

  - ### setAWTThreadProtection

    public void setAWTThreadProtection(boolean awtThreadProtection)

  - ### isGcDaemonProtection

    public boolean isGcDaemonProtection()

  - ### setGcDaemonProtection

    public void setGcDaemonProtection(boolean gcDaemonProtection)

  - ### isTokenPollerProtection

    public boolean isTokenPollerProtection()

  - ### setTokenPollerProtection

    public void setTokenPollerProtection(boolean tokenPollerProtection)

  - ### isUrlCacheProtection

    public boolean isUrlCacheProtection()
    Get the URL cache protection flag.
    Returns:
      the URL cache protection flag

  - ### setUrlCacheProtection

    public void setUrlCacheProtection(boolean urlCacheProtection)
    Set the URL cache protection flag.
    Parameters:
      `urlCacheProtection` - the flag to set

  - ### isXmlParsingProtection

    public boolean isXmlParsingProtection()

  - ### setXmlParsingProtection

    public void setXmlParsingProtection(boolean xmlParsingProtection)

  - ### isLdapPoolProtection

    public boolean isLdapPoolProtection()

  - ### setLdapPoolProtection

    public void setLdapPoolProtection(boolean ldapPoolProtection)

  - ### isDriverManagerProtection

    public boolean isDriverManagerProtection()
    Get the DriverManager protection flag.
    Returns:
      the DriverManager protection flag

  - ### setDriverManagerProtection

    public void setDriverManagerProtection(boolean driverManagerProtection)
    Set the DriverManager protection flag.
    Parameters:
      `driverManagerProtection` - the flag to set

  - ### getForkJoinCommonPoolProtection

    public boolean getForkJoinCommonPoolProtection()

  - ### setForkJoinCommonPoolProtection

    public void setForkJoinCommonPoolProtection(boolean forkJoinCommonPoolProtection)

  - ### getClassesToInitialize

    public String getClassesToInitialize()
    Get the classes to initialize.
    Returns:
      the classes to initialize

  - ### setClassesToInitialize

    public void setClassesToInitialize(String classesToInitialize)
    Set the classes to initialize.
    Parameters:
      `classesToInitialize` - the classes to initialize

  - ### getInitSeedGenerator

    public boolean getInitSeedGenerator()
    Get the init seed generator flag.
    Returns:
      the init seed generator flag

  - ### setInitSeedGenerator

    public void setInitSeedGenerator(boolean initSeedGenerator)
    Set the init seed generator flag.
    Parameters:
      `initSeedGenerator` - the flag to set

  - ### 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