Appendix A. JavaAPI Classes in which Leakage of the Java Heap Memory Occurs Easily

When you use a JavaAPI class, the instances of the JavaAPI class are created in the Java heap memory. However, when the methods of the JavaAPI classes, described in Table A-1 and Table A-2, are used and the conditions described in the tables are fulfilled, the instances other than the JavaAPI classes will also be also created in the Java heap memory.

The created instances of the user-created classes are stored in the Java heap memory until the JavaAPI classes are deleted. Therefore, before you realize it, the usage of the Java heap memory might increase and leakage of the Java heap memory might occur.

However, as for the JavaAPI classes described in Table A-2, you can also delete the instances of the user-created classes.

The classes in which leakage of the Java heap memory occurs easily are listed in separate tables below, depending on the existence of the methods for deleting the instances. Table A-2 also describes the methods for deleting the user-created instances.

Reference note
Some changes might be made in the version 08-00 and later versions regarding the JavaAPI classes in which leakage of the Java heap memory occurs easily, and the conditions of leakage and the methods for deleting the instances of the user-created classes.

Table A-1 List of classes in which leakage of the Java heap memory occurs easily (When no deletion method exists)

JavaAPI class nameConditions for creating instances of the user-created classes in the Java heap memory
java.lang.ClassLoaderWhen ProtectionDomain, specified in an argument of the defineClass() method, is correlated to a user-created class.
java.net.URLWhen the URLStreamHander class, created by URLStreamHandlerFactory during the creation of the URL class instances, is a user-created class.
java.text.DateFormatWhen super() is invoked by the constructor of a user-created class that inherits the DateFormat class.
java.util.logging.LevelWhen super() is invoked by the constructor of a user-created class that inherits the Level class.
java.util.logging.LogManagerWhen a user-created class, that inherits the Logger class in the argument of the addLogger() method, is specified.
java.util.logging.LoggerWhen the getAnonymousLogger() method and the setParent() method are invoked by a user-created class that inherits the Logger class.
javax.accessibility.AccessibleBundleWhen a user class object is set up in a value of a pair that consists of a key and a value maintained in a user-implemented class corresponding to the resource bundle name specified in the argument of the toDisplayString() method.
javax.print.attribute.standard.MediaSizeWhen super() is invoked by the constructor of a user-created class that inherits the MediaSize class.
java.rmi.server.UnicastRemoteObjectWhen a user-created class is specified in the arguments (RMIClientSocketFactory and RMIServerSocketFactory) of the exportObject() method.

Table A-2 List of classes in which leakage of the Java heap memory occurs easily (When a deletion method exists)

JavaAPI class nameConditions for creating instances of the user-created classes in the Java heap memoryMethod for deleting the instances of the user-created classes
java.beans.IntrospectorWhen a user-created class is specified in an argument (beanClass) of the getBeanInfo() method.Execute the flushCaches() method and the flushFromCaches() method.
java.beans.PropertyEditorManagerWhen a user-created class is specified in an argument (editorClass) of the registerEditor() method.Specify null in editorClass of the registerEditor() method.
java.util.logging.LoggerWhen a user-created class that inherits the Handler class is specified in an argument of the addHandler() method.Execute the removeHandler() method.
javax.imageio.ImageReaderWhen a user-created class that inherits the IIOReadWarningListener class is specified in an argument of the addIIOReadWarningListener() method.Execute the removeIIOReadWarningListener() method.
When a user-created class that inherits the IIOReadProgressListener class is specified in an argument of the addIIOReadProgressListener() method.Execute the removeIIOReadProgressListener() method.
When a user-created class that inherits the IIOReadUpdateListener class is specified in an argument of the addIIOReadUpdateListener() method.Execute the removeIIOReadUpdateListener() method.
javax.imageio.ImageWriterWhen a user-created class that inherits the IIOWriteProgressListener class is specified in an argument of the addIIOWriteProgressListener() method.Execute the removeIIOWriteProgressListener() method.
When a user-created class that inherits the IIOWriteWarningListener class is specified in an argument of the addIIOWriteWarningListener() method.Execute the removeIIOWriteWarningListener() method.
javax.naming.InitialContextWhen a user-created class is specified in an argument (propVal) of the addToEnvironment() method.Execute the removeFromEnvironment() method.
javax.naming.spi.NamingManagerWhen a user-created class is specified in an argument of the getContinuationContext() method.Implement close() of the acquired Context, and then execute super().
javax.print.attribute.HashAttributeSetWhen a user-created class is specified in an argument of the add() method.Execute the remove(Attribute) method and remove(Class) method.