1

How does a binder cleanup memory when this.mojitProxy.refreshView is called?

On the YUI-forum, there is a interesting discussion about the best way to clean up memory in widgets (http://yuilibrary.com/forum/viewtopic.php?f=18&t=10914). I asked a question there about how Mojito handles this, but no answer. Perhaps this is a better place.

My question is:
If you should call this.mojitProxy.refreshView(); from within a binder, what happens to all Nodes and eventlisteners I have attached?

I'm used to set 

onRefreshView: function (node) {
this.bind(node);
}

Which could lead to some problems when refreshView() is called I'm afraid.
YUI3-Widgets have a destructor() in which I can cleanup things to avoid memoryleaks. Is there a same way to do this in the binder?

Marco.

4 Replies
  • Great Question!

    onRefreshView will trigger refreshMojitView internally

    You can look at the code here https://github.com/yahoo/mojito/blob/develop/lib/app/autoload/mojito-client.client.js

    It attaches new (instance ) of binders , m not sure about older eventListeners. I hope YUI clears them when DOM nodes are removed.

    I Will wait to see some response from Mojito Contributors

    0
  • Hey Markandey, I looked at the code, but couldn't find any.

    YUI could do so, but doesn't do this standard. You need to call node.destroy(true) in order to do so.
    Besides, if you have any object-structures like widgets defined, they need to be destroyed as well. Just replacing the node isn't enough.

    There is a function onRefreshView, which executes just after refreshView.
    Is there a function available which alway executes just before refreshView ? (if defined) ?
    Then we can use this to do any necessary cleanup ourselves.

    Marco.

    QUOTE(Markandey Singh @ 5 Nov 2012 11:47 PM)

    Great Question!

    onRefreshView will trigger refreshMojitView internally

    You can look at the code here https://github.com/yahoo/mojito/blob/develop/lib/app/autoload/mojito-client.client.js

    It attaches new (instance ) of binders , m not sure about older eventListeners. I hope YUI clears them when DOM nodes are removed.

    I Will wait to see some response from Mojito Contributors

    0
  • Looking at the documentation here

    http://developer.yahoo.com/cocktails/mojito/api/classes/MojitProxy.htm

    I Don't think Mojito have any event which might trigger just before the refreshMojitView call. but since your code will be calling this method, you can always wrap this call within your own method and do proper cleaning before calling refreshView..

    Mojito is extensible , you can extend MojitoProxy by copying mojit-proxy.client.js in your "/<application-directory>/autoload/".

    0
  • Yeah, I'll do so. Thanks.

    It is still a tricky matter though, calling refreshView. Today, there is a ticket created for YUI to develop a garbagecollector (http://yuilibrary.com/projects/yui3/ticket/2532944). I hope this can be created for it will also help in this matter.

    Marco.

    0

Recent Posts

in Yahoo! Mojito