You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Oliver Heger (JIRA)" <ji...@apache.org> on 2015/01/24 18:10:34 UTC
[jira] [Commented] (CONFIGURATION-596) Allow event listener
Collections to be lazily created in event.EventSource
[ https://issues.apache.org/jira/browse/CONFIGURATION-596?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14290714#comment-14290714 ]
Oliver Heger commented on CONFIGURATION-596:
--------------------------------------------
In version 1.x, {{AbstractConfiguration}} creates one collection object for normal listeners and one for error listeners. In version 2.0 (currently in alpha state), there is only a single list managing all registered event listeners.
Do you have concrete numbers that these objects acutally cause a measurable overhead? After all, they are just empty {{CopyOnWriteArrayList}} objects. We could create them with a low initial capacity (as most applications are not expected to register many listeners), but this will only save a few bytes.
Using lazy initialization to overcome this has its own problems: There is a runtime overhead each time the lists are accessed, null checks would have to be added, and you would need a means of synchronization to ensure thread-safe access. In addition, some concrete configuration implementations register a special error listener which just logs occurring exceptions; in such cases, nothing is gained.
> Allow event listener Collections to be lazily created in event.EventSource
> --------------------------------------------------------------------------
>
> Key: CONFIGURATION-596
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-596
> Project: Commons Configuration
> Issue Type: Improvement
> Components: Events & Notifications
> Affects Versions: 1.9
> Reporter: Vladimir Sitnikov
>
> It turns out every instance of {{AbstractConfiguration}} creates a couple of {{CopyOnWriteAraryLists}} for {{event.EventSource}}.
> In our usage patterns in most of the cases the lists are not used.
> Can the lists be lazy-initialized? (that is created on the first addListener request)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)