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 41272 - Memory leak in PersistenceManager
Summary: Memory leak in PersistenceManager
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Window System (show other bugs)
Version: 3.x
Hardware: All All
: P3 blocker (vote)
Assignee: mslama
URL:
Keywords: PERFORMANCE
Depends on:
Blocks: 109098
  Show dependency tree
 
Reported: 2004-03-24 14:32 UTC by Petr Nejedly
Modified: 2008-12-22 14:39 UTC (History)
1 user (show)

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 Petr Nejedly 2004-03-24 14:32:09 UTC
a globalIDSet Set if continuously filled with
newly created IDs and not cleaned.
Try opening and closing a.form 5 times, it will
hold 5 new strings:
a, a_1, a_2, a_3, a_4

Also, the id2TopComponentMap gets polluted with
mappings from the above mentioned strings to
empty WeakReferences.
Comment 1 Milos Kleint 2004-03-25 13:38:22 UTC
reassigning
Comment 2 Milos Kleint 2004-07-30 10:01:53 UTC
should be fixed now.
Comment 3 Zdenek Konecny 2005-07-13 15:23:47 UTC
Closed. It's too old.
Comment 4 mslama 2007-08-07 17:39:23 UTC
This fix is completely wrong as it allows 2 different TC IDs to be assigned to the same TC instance. Cleaning of maps
and cache must be done AFTER TC instance is gc'ed to make sure different TC ID is not assigned to the same TC instance.
See issue #109098 for demonstration of this incorrect behavior. Petr suggested solution using
Utilities.activeReferenceQueue. I am working on it now.
Comment 5 mslama 2007-08-08 20:45:20 UTC
Fixed in main trunk. Internal maps are cleared AFTER TC is gc'ed.

Modified:
/cvs/core/windows/src/org/netbeans/core/windows/Central.java
new revision: 1.63; previous revision: 1.62

/cvs/core/windows/src/org/netbeans/core/windows/persistence/PersistenceManager.java
new revision: 1.45; previous revision: 1.44
Comment 6 mslama 2007-08-08 21:12:05 UTC
Note: Current fix clears only id2TopComponentMap and id2TopComponentNonPersistentMap NOT globalIDSet. It is because for
TC with persistence type PERSISTENCE_ONLY_OPENED there can be already settings file with the same name ie. <TC
ID>.settings so this TC ID is blocked anyway. Cleaning of unused settings files is done during start of new session.
This follows rule that globalIDSet contains all already used TC IDs during one session. Unfortunately I am not able to
identify persistence type of given TC only from TC ID. For persistence type PERSISTENCE_NEVER is is good to clean even
globalIDSet.

Another possible solution would be to delete corresponding settings file if TC is gc'ed. In this case settings file can
be present only for PERSISTENCE_ONLY_OPENED as for persistent TC TC should not be gc'ed and for nonpersistent TC
setiings file is not created. This scenario can happen in case:
1.User opens editor.
2.Exits IDE. Settings file for editor tc is created.
3.Start IDE again, user closes editor tc, gc is run, tc is is gc'ed ie. tc ends its existence forever. It is now safe to
delete even settings file.

If you think it is worth to fix this case please reopen issue.