a caveat on using EventHandler object.
When you attach an event to an object using EventHandler, an EventObject is created and stored in the EventRegistry.
The EventRegistry is used to detach events from the page when page unloads.
So, if you continue to attach more and more events to the page dynamically at runtime, the EventRegistry will grow bigger and bigger. This may result in a pseudo-leak.
There are several options you may choose to bypass addition to the event registry.
You may do it a attachment time:
EventHandler.addEventListener("myObject", "click",
myObject_click,true);
The last parameter true will indicate that the addition to EventRegistry will bypassed. As a consequence, memory leak issues will not be handled by sardalya engine and you will have to relase the memory yourself (by breaking circular references manually, you may want to visit my codeproject article for more info, it is not as difficult as it seems :))
Another option is to use a more simplistic event attachment model:
document.getElementById("myObject").onclikc=myObject_click;
... later in the code ...
function myObject_click(evt)
{
... event handling logic comes here ...
}
Hope that helps.

0 Comments:
Post a Comment
<< Home