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 31034

Summary: TimedSoftReference tweaks
Product: platform Reporter: Jesse Glick <jglick>
Component: -- Other --Assignee: Petr Nejedly <pnejedly>
Status: RESOLVED FIXED    
Severity: blocker Keywords: PERFORMANCE
Priority: P4    
Version: 3.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:
Bug Depends on:    
Bug Blocks: 13847    

Description Jesse Glick 2003-02-13 16:30:41 UTC
From #13847:

I've looked at the TimedSoftRef. Functionally is
it OK,
but I'd suggest using a bit smarter scheme for
timeout impl:
The (re)schedule call is relatively expensive, it
does some
synchronization, allocates some objects and, worst
of all,
each schedule(time!=0) leaves a trail in the
TimerTask, a runnable
that will be executed (and possibly do nothing).
So the current impl would behave poorly for
sequences of get().

I suggest using this approach:
On first get() schedule a task (now+30000) and
record the
time-to-clear (now+30000). For subsequent get()s
(TTC is nonzero),
just update the TTC to now+30000.
In the timeout handler, compare "now" to TTC and
if it is bigger,
clear the reference and clear the TTC, otherwise
reschedule the task
using schedule(TTC-now).
That means at most one reschedule each 30000ms per
reference.

Maybe it can be implemented directly in the RPs
reschedule,
but this way it it quite isolated and simple code.
Comment 1 Jesse Glick 2003-02-13 16:31:27 UTC
Or assign back to me if you prefer, but it sounds like you already
know what to do with it.
Comment 2 Petr Nejedly 2003-02-25 12:23:16 UTC
OK done using the technique similar to my original suggestion.