Skip to content
This repository was archived by the owner on Jan 30, 2019. It is now read-only.
This repository was archived by the owner on Jan 30, 2019. It is now read-only.

Java Help 2_0_05 Memory Leak in FlatMap #32

@glassfishrobot

Description

@glassfishrobot

We have a Java Desktop Application which uses JavaHelp library to show Help Content.

From "Main Java Window", we launch another "JFrame Window". The later "JFrame Window" can be closed and opened several times when "Main Java Window" is still alive.

"JFrame Window" used JavaHelp and creates HelpSet etc. When we close the "JFrame Window" we call cleanup method on HelpSet and HelpBroker object and assign the object=null.

Note that we have large number of help html files. But it is observed that JavaHelp's FlatMap object is not getting released for after closing "JFrame Window" (Even after running GC). "FlatMap" has "FlatMapResourceBundle" inner class which has got "lookup" hashtable. This "lookup" hashtable is storing big chunk of memory.

I've written the sample example to re-create the issue.

Request you to follow below instructions.

  1. Download attached sample zip file. Extract it. This has doc, lib, src directory.
  2. Download http://download.java.net/javadesktop/javahelp/javahelp2_0_05.zip and put "jhall.jar" in lib directory.
  3. You need large number of html files. We use Java Help Documentation
    Goto http://www.oracle.com/technetwork/java/javase/downloads/index-jdk5-jsp-142662.html#docs
    Navigate to the "J2SE 5.0 Documentation" on the same page and click "download" to download "jdk-1_5_0-doc.zip" (Follow the page to download as instructed).
  4. Just extract above download documentation into "doc" directory.
  5. The sample program is very very generic as it generates helpset, map files too.
  • 1. Creates Map file from given directory containing set of HTML files (JDK Documentation)
  • 2. Creates HelpSet
  • 3. Put the thread to Sleep for about 5 seconds
  • 4. Cleanup HelpSet
  • 5. Force Java Garbage Collection
  • 6. Repeat 2 to 5 about 10 times
  • 7. Wait for user input so that you can check for memory leak

CD to "src" directory and compile and run the sample as shown below.

Compile
javac -classpath ..\lib\jhall.jar com\org\test\memory\TestJavaHelpMem.java

Run
java -classpath .;..\lib\jhall.jar com.org.test.memory.TestJavaHelpMem "..\doc"

Now what we need

We need a API (a cleanup function) to remove the memory chunk held by FlatMap::FlatMapResourceBundle::lookup table.
Also have a look at cleanup the memory reference around it.

Environment

Windows 2003 Professional, Java Help 2_0_05, Java version "1.6.0_25"

Affected Versions

[current]

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions