This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 206621 - Lookup leaks perm gen space
Summary: Lookup leaks perm gen space
Alias: None
Product: platform
Classification: Unclassified
Component: Lookup (show other bugs)
Version: 7.2
Hardware: Other Linux
: P2 normal (vote)
Assignee: Jaroslav Tulach
: 232437 (view as bug list)
Depends on:
Blocks: 245732
  Show dependency tree
Reported: 2011-12-21 14:35 UTC by Jaroslav Tulach
Modified: 2014-07-28 15:01 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:

Two tests showing the problem and a brute-force fix of one of them (14.66 KB, patch)
2012-01-04 16:32 UTC, Jaroslav Tulach
Details | Diff
org-openide-util-lookup.jar with the fix (354.24 KB, application/octet-stream)
2012-01-05 12:30 UTC, Jaroslav Tulach

Note You need to log in before you can comment on or make changes to this bug.
Description Jaroslav Tulach 2011-12-21 14:35:56 UTC
In order to move to simpler module assembly and deployment in our web
applications, I decided to give the META-INF/services a try. That would
allow us to deploy different implementations (jars) to different customers,
each having the implementation that fits them best. Originally I used the
JDK ServiceLoader, but that API is rather limited, for example lacking
notification of changes.

So I switched to the Lookup API, although I know it was designed for
desktop applications, not for long-running server software. This change
immediately caused a memory leak when the webapp was unloaded. Within a few
reloads we got a PermGen OutOfMemory exception. That turned out to be a
Timer thread that could never be cancel()-ed. We were still using an older
version of the lookup library, so I switched to the new one, from NetBeans
7, platform/lib/org-openide-util-lookup.jar and org-openide-util.jar.
Unfortunately, the RequestProcessor class from org-openide-util.jar still
suffers from the same problem.

It turned out this is caused by my LookupListener. Adding a LookupListener
caused several threads to start (and never end). One thread is a Timer
thread (Timer-0, Timer-1 etc), another one is called "Active Reference
Queue Daemon". As long as I avoid the event notification functionality of
Lookup, everything is working fine. Is there anything I can do to end those
Comment 1 Jaroslav Tulach 2012-01-04 16:32:56 UTC
Created attachment 114634 [details]
Two tests showing the problem and a brute-force fix of one of them
Comment 2 Jaroslav Tulach 2012-01-05 12:29:24 UTC
Comment 3 Jaroslav Tulach 2012-01-05 12:30:43 UTC
Created attachment 114656 [details]
org-openide-util-lookup.jar with the fix
Comment 4 Quality Engineering 2012-01-06 15:44:59 UTC
Integrated into 'main-golden'
User: Jaroslav Tulach <>
Log: #206621: Worker threads in ActiveQueue and RequestProcessor are able to cancel itself, when these subsystems are no longer needed.
Comment 5 Jaroslav Tulach 2014-07-28 15:01:43 UTC
*** Bug 232437 has been marked as a duplicate of this bug. ***