[
https://issues.apache.org/jira/browse/XERCESJ-1301?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ludger Bünger updated XERCESJ-1301:
-----------------------------------
Attachment: WeakEventListenerPatch.txt
The following patch to DocumentImpl changes the eventListener HashTable to a
weakHashTable allowing garbage collection of event listeners.
However, updating listener counting in LCount is far less trivial:
First:
We need a ReferenceQueue that queues all WeakReferences we need to keep trace
of, i.e. all nodes with an eventListener registered upon that have been garbage
collected.
Second:
We need to prevent that the EventListeners themself are garbage collected
before LCount has been updated. This is easiest done using a non-weak HashTable
with above WeakReference objects as key and the eventListeners to the weak
referenced node as value.
With these data structures we can easily detect node garbage collection of
nodes that have eventListeners registered upon them and update LCount
accordingly.
Third:
However we also need to be able to update the non-weak Hashtable, especially if
the last event listener of a node has been unregistered.
While this could be done iterating over all value entries of the HashTable
mentioned in "Second", this would be inefficient for large documents with lots
of event listeners, so we need another HashMap containing a mapping from all
nodes to the references of the nodes.
If we make it itself "weak" this data structure will update itself upon garbage
collection of nodes.
> EventListeners should be garbage collectable if the nodes the listeners are
> registered upon are garbage collected
> -----------------------------------------------------------------------------------------------------------------
>
> Key: XERCESJ-1301
> URL: https://issues.apache.org/jira/browse/XERCESJ-1301
> Project: Xerces2-J
> Issue Type: Improvement
> Components: DOM (Level 2 Events)
> Affects Versions: 2.9.1
> Reporter: Ludger Bünger
> Priority: Trivial
> Attachments: WeakEventListenerPatch.txt
>
>
> EventListeners should be garbage collectable if the nodes the listeners are
> registered upon are garbage collected
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]