<div dir="ltr">I have another idea: event handle properties (like `ButtonBase#onActionProperty()`) are frequently set, but rarely have listeners added.<br>I think we can initialize these properties more lazily.<br><br>We can add the following method to `Node`:<br><br><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><font face="monospace">protected final <T extends Event> EventHandler<? super T> getEventHandler(final EventType<T> eventType) {<br>    getInternalEventDispatcher().getEventHandlerManager().getEventHandler(eventType);<br>}</font></blockquote><br>Then we can implement `onActionProperty()` like this:<br><br><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><font face="monospace">private ObjectProperty<EventHandler<ActionEvent>> onAction;<br><br></font><font face="monospace">public EventHandler<ActionEvent> getOnAction() {<br></font><font face="monospace">    return onAction != null ? onAction.get() : (EventHandler<ActionEvent>) getEventHandler(ActionEvent.ACTION);<br></font><font face="monospace">}<br><br></font><font face="monospace">public void setOnAction(EventHandler<ActionEvent> value) {<br></font><font face="monospace">    if (onAction != null)<br></font><font face="monospace">        onAction.set(value);<br></font><font face="monospace">    else<br></font><font face="monospace">        setEventHandler(ActionEvent.ACTION, value);<br></font><font face="monospace">}<br><br></font><font face="monospace">public ObjectProperty<EventHandler<ActionEvent>> onActionProperty() {<br></font><font face="monospace">    if (onAction == null) {<br></font><font face="monospace">        onAction = new ObjectPropertyBase<>((EventHandler<ActionEvent>) getEventHandler(ActionEvent.ACTION)) {<br></font><font face="monospace">            @Override<br></font><font face="monospace">            public Object getBean() {<br></font><font face="monospace">                return ButtonBase.this;<br></font><font face="monospace">            }<br></font><font face="monospace">            @Override<br></font><font face="monospace">            public String getName() {<br></font><font face="monospace">                return "onAction";<br></font><font face="monospace">            }<br></font><font face="monospace">            @Override<br></font><font face="monospace">            protected void invalidated() {<br></font><font face="monospace">                setEventHandler(ActionEvent.ACTION, get());<br></font><font face="monospace">            }<br></font><font face="monospace">        };<br></font><font face="monospace">    }<br></font><font face="monospace">    return onAction;<br></font><font face="monospace">}</font></blockquote><br>This allows us to eliminate the allocation of many properties.<br>Although there is a slight risk (the behavior will change slightly if the user updates the handler value with `setEventHandler(ActionEvent.ACTION, ...)` before calling `onActionProperty()`/`getOnAction()`), I think it is worthwhile.<br><div><br></div><div>Glavo</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, Feb 5, 2026 at 5:17 AM Andy Goryachev <<a href="mailto:andy.goryachev@oracle.com">andy.goryachev@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div>
<div style="direction:ltr;font-family:"Iosevka Fixed SS16",Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I would like to share the results of a little experiment involving optimization of storage of Node properties.  The basic idea is to create a compact fast map-like container to hold the rarely instantiated properties in order to reduce the application memory
 footprint.</div>
<div style="direction:ltr;font-family:"Iosevka Fixed SS16",Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="direction:ltr;font-family:"Iosevka Fixed SS16",Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
The savings are not overwhelming, but not exactly zero.  I would imagine this optimization might be more interesting in any resource constrained environment such as Android / iOS / RaspberryPi.  Please refer to [0] for the details.</div>
<div style="direction:ltr;font-family:"Iosevka Fixed SS16",Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="direction:ltr;font-family:"Iosevka Fixed SS16",Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I encourage you to try it with your application, to see whether you notice any change in memory consumption and/or performance.  Let me know what you think!</div>
<div style="direction:ltr;font-family:"Iosevka Fixed SS16",Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="direction:ltr;font-family:"Iosevka Fixed SS16",Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Cheers,</div>
<div style="direction:ltr;font-family:"Iosevka Fixed SS16",Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
-andy</div>
<div style="direction:ltr;font-family:"Iosevka Fixed SS16",Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="direction:ltr;font-family:"Iosevka Fixed SS16",Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="direction:ltr;font-family:"Iosevka Fixed SS16",Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<b>References</b></div>
<div style="direction:ltr;font-family:"Iosevka Fixed SS16",Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="direction:ltr;font-family:"Iosevka Fixed SS16",Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
[0] <a href="https://github.com/andy-goryachev-oracle/Test/blob/main/doc/Experiments/NodeProperties.md" target="_blank">
https://github.com/andy-goryachev-oracle/Test/blob/main/doc/Experiments/NodeProperties.md</a></div>
<div style="direction:ltr;font-family:"Iosevka Fixed SS16",Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</div>
</div>

</blockquote></div>