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 19694 - Memory leak in PositionRef$Manager
Summary: Memory leak in PositionRef$Manager
Status: CLOSED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Text (show other bugs)
Version: 3.x
Hardware: Sun Solaris
: P2 blocker (vote)
Assignee: Peter Zavadsky
URL:
Keywords: PERFORMANCE
Depends on:
Blocks: 19885
  Show dependency tree
 
Reported: 2002-01-23 14:38 UTC by Petr Nejedly
Modified: 2008-12-22 21:52 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Diff of proposed patch (8.05 KB, patch)
2002-01-25 13:35 UTC, Peter Zavadsky
Details | Diff
Proposed patch (lib/patches dir) (14.82 KB, application/zip)
2002-01-25 13:37 UTC, Peter Zavadsky
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Nejedly 2002-01-23 14:38:36 UTC
PositionRef$Manager keeps WeakReferences to Positions,
but don't neither the references nor the LinkList$Items pointing to them.
It should register the References to a reference queue and remove
them (periodically).
Also, holding the References in the LinkedList has high memory overhead,
as the LL$Item is itself as big as the Reference itself.
Implement some internal linkage scheme instead of using LinkedList.
Comment 1 Petr Nejedly 2002-01-23 14:46:50 UTC
see
http://www.netbeans.org/servlets/ReadMsg?msgId=243074&listName=nbdev

for outline of a solution
Comment 2 Peter Zavadsky 2002-01-25 13:00:13 UTC
There is also related issue to this one #19780.
Comment 3 Peter Zavadsky 2002-01-25 13:35:42 UTC
Created attachment 4420 [details]
Diff of proposed patch
Comment 4 Peter Zavadsky 2002-01-25 13:37:20 UTC
Created attachment 4421 [details]
Proposed patch (lib/patches dir)
Comment 5 Peter Zavadsky 2002-01-25 15:15:29 UTC
Petr, please look at it if it is the what we need.

I tested it just from the point how often the sweeping is scheduled
and how fast it is.
The sweeping task takes up to 4ms (0ms for small sources, 4ms for
larger sources), seemed to work in reasonable intervals.
Comment 6 Jaroslav Tulach 2002-01-28 03:04:33 UTC
Patch looks fine. Btw. what do you think I did last week:
http://www.netbeans.org/source/browse/openidex/looks/src/org/netbeans/api/looks/Attic/Look.java.diff?r1=1.1.2.14&r2=1.1.2.15
Comment 7 Petr Nejedly 2002-01-28 10:37:32 UTC
Peter: You've got the idea, now make the "next" public for simplier
access, inline the sweeping pass to the conversion (you're going to
iterate over the whole array anyway so why to schedule the cleaning
to happen just after (or worse - during) the conversion) and do less
grained locking (while() { synchronized() {}} is not the best thing.
The only thing that is missing there is some periodic sweep
which is still needed because of #19780 and similar access patterns.
But I'd rather design some generic support for it first...

Yarda: Inlined collections are nice thing, espacially if they
are absolutely memory penalty free.
I know little about your changed class but I believe your chains
will be short enough to not need RQ and periodic cleaning.
Comment 8 Peter Zavadsky 2002-01-28 14:25:50 UTC
Fixed in [main-trunk]

Fix:
openide/../text/PostionRef.java [1.42]

Note: I applied to the fix Petr's refinements from prev comment.
Comment 9 Petr Nejedly 2002-01-28 17:24:11 UTC
The impelentation you checked in has a problem of not converting
the last item in the list. Also the bound checking
can be implemented in a simplier way. I'll commit a better version
tomorrow (I've already prepared it).
Comment 10 Petr Nejedly 2002-01-29 09:35:13 UTC
Finally fixed.
Who will verify it for me? :-)
Comment 11 pzajac 2002-10-21 13:02:52 UTC
verified
Comment 12 Quality Engineering 2003-07-01 16:36:59 UTC
Resolved for 3.4.x or earlier, no new info since then -> closing.