coffeescript - jQuery circular reference -
i made jquery plugin/widget oop object , in object saving html/jquery element ($elem
) property. storing object's reference (created using new
) in data
attribute of html element. cause circular reference/memory leakage?
the code in coffeescript be:
class wid constructor @$elem = $('<div>hello</div>') @$elem.appendto('body') @$elem.data('obj',@) // adding instance element's data attribute updatetext: (p)-> @$ele.text(p) widget = new wid()
on real browser, no. internet explorer, microsoft's browser-shaped object, has separate garbage collectors dom , javascript, it's easy create circular references. since ie tightly integrated operating system, merely shutting down browser not free memory: os has rebooted.
however, thing: ie becomes slower , slower, weighed down unfreed object references, user learns vital lesson microsoft quality.
Comments
Post a Comment