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.
Summary: | Introduce callback references in place of activeReferenceQueue | ||
---|---|---|---|
Product: | platform | Reporter: | Martin Entlicher <mentlicher> |
Component: | -- Other -- | Assignee: | apireviews <apireviews> |
Status: | NEW --- | ||
Severity: | normal | CC: | mentlicher |
Priority: | P2 | Keywords: | API, API_REVIEW_FAST |
Version: | 8.2 | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | ENHANCEMENT | Exception Reporter: | |
Attachments: |
The proposed CallbackReferences API
New proposed CallbackReferences API Changed usages from old Utilities.activeReferenceQueue() to new CallbackReferences |
Description
Martin Entlicher
2015-12-07 08:55:48 UTC
Created attachment 157714 [details]
The proposed CallbackReferences API
Please review the proposed API change. Unfortunately, the first proposal has some problems. The use of finalizers is causing troubles, sometimes finalizers are called for objects (instances of Reference) which were placed into the ReferenceQueue and therefore callbacks were discarded before they should be executed. Also this proposal is increasing memory usage of these "active" callback references. I'm about to attach a significantly reworked proposal with additional tests. Created attachment 157767 [details]
New proposed CallbackReferences API
I'm attaching the new proposal.
Regarding naming, I was hesitating between CallbackReferences and ActiveReferences, if someone prefers a different name from the proposed one, it's easy to rename.
There are two implementations of the background thread:
1. In NetBeans IDE, it's impossible to occur that at some point in time all callback references would be processed and the thread could be shut down. Therefore the extra memory usage caused by control references checking the GC, is just a waste of memory space. Therefore the IDE sets system property netbeans.CallbackReferences.delayShutdownOfCallbackThread=infinity which selects the indefinite background thread (old ActiveQueue) and adds no overhead with respect to the original implementation.
2. By default, to keep compatibility, a finishable background thread is used, but it adds an overhead of one extra weak reference having one int field.
Tests are added.
Created attachment 157768 [details]
Changed usages from old Utilities.activeReferenceQueue() to new CallbackReferences
Usages changed throughout the NetBeans code base.
Since the usages of activeReferenceQueue() are spread throughout the NetBeans codebase, I'll wait with the integration until after all fixes for 8.1 patch 1 are done and merge into the fixes branch, in order not to complicate the backport. |