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 104329 - WebProject object memory leak in JsfProjectUtils
Summary: WebProject object memory leak in JsfProjectUtils
Status: VERIFIED FIXED
Alias: None
Product: obsolete
Classification: Unclassified
Component: visualweb (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: _ potingwu
URL:
Keywords: PERFORMANCE
Depends on:
Blocks: 104333
  Show dependency tree
 
Reported: 2007-05-18 22:53 UTC by Quy Nguyen
Modified: 2007-06-27 13:24 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Quy Nguyen 2007-05-18 22:53:51 UTC
The JsfProjectUtils.JavaEE5Project field causes a memory leak of WebProject
objects.  This static map never removes entries, so the project objects will
stay in memory.

This has been assigned as a P1 since it may potentially block the detection of
other memory leaks.
Comment 1 _ potingwu 2007-05-18 23:08:17 UTC
Why the other JsfProjectUtils.propertyListeners field does not have the same
issue? This code was somehow copied from NetBeans long ago. NetBeans has many of
this kind of cache implementation as I seen. Please advise the alternative.
Comment 2 Quy Nguyen 2007-05-22 00:57:47 UTC
I checked again and the JsfProjectUtils.propertyListeners field also has the
same problem, but it was more difficult to find since the NB profiler heap
walker only finds a single GC root.

One possible way to solve this would be to change both fields to WeakHashMap to
avoid the memory leak.  Assuming the WebProject object lifecycle is managed
elsewhere, this solution should work correctly.
Comment 3 _ potingwu 2007-05-23 18:28:40 UTC
There are few ways to not holding closed project; by using project root
DataFolder or root-path String as the Key instead of Project itself.

However, I just fixed it by replacing HashMap by WeakHashMap as you suggested. I
searched NetBeans web area that they also have many of this kind of cache. But I
only found usage of WeakHashMap in 'our' web/jsf/navigation! I'm hoping NetBeans
itself won't have this memory leak issue and hoping this 'Weak' stuffs won't
introduce any new regression.
Comment 4 Dan Kolar 2007-06-27 13:24:24 UTC
v. 20070624180000