Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!

Bug 206621

Summary: Lookup leaks perm gen space
Product: platform Reporter: Jaroslav Tulach <jtulach>
Component: LookupAssignee: Jaroslav Tulach <jtulach>
Status: RESOLVED FIXED QA Contact: issues <issues.netbeans.org>
Priority: P2 CC: cyhelsky, thurka
Version: 7.2   
Target Milestone: 7.2   
Hardware: Other   
OS: Linux   
Whiteboard:
Issue Type: DEFECT Exception Report:
Bug Depends on:    
Bug Blocks: 245732    
Attachments: Two tests showing the problem and a brute-force fix of one of them
org-openide-util-lookup.jar with the fix

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
threads?
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
ergonomics#65559f0f82fd
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'
Changeset: http://hg.netbeans.org/main-golden/rev/65559f0f82fd
User: Jaroslav Tulach <jtulach@netbeans.org>
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. ***
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo