Monday, 15 February 2010

javascript - Memory Leak in official AngularJS UI Bootstrap $modal sample? -



javascript - Memory Leak in official AngularJS UI Bootstrap $modal sample? -

i'm trying understand how avoid memory leaks in angularjs. there seems no documentation clean up, 1 expect if garbage collection perfect , omniscient. however, reading indicates it's easy leave bound dom elements prevent garbage collection, stackoverflow answer says must manually unbind bindings set in directives, , on smaller scale, clean $timeouts well. came across this article, instructs me "detached" dom elements.

using sample $modal code angularjs ui site, find numerous sizable detached elements after opening , closing modal dialog. doesn't seem grow repeated clicking, if have many dialogs, each 1 leaves footprint seemingly forever. tried setting modalinstance = null after close, didn't accomplish anything.

are detached elements bad? if so, how should angularjs ui sample modal code modified eliminate these?

more importantly, there simple, clear, instructions clean when using angularjs? it's nice provide $on.$destroy function, can't find clear instructions indicating i'm responsible cleaning up, or how it.

i afraid detached elements more complex problem leads uncontrolled memory leaking. researched way remove problem me. , native ui.bootstrap modal behaviour can changed via custom $modal mill prevents destroying , reinstantiating of dialog. $modal dialog becomes singleton.

i've shared seek of solution @ github: https://github.com/dhilt/angular-bootstrap-modal-singleton. , utilize in projects working on.

javascript angularjs memory-leaks angular-ui-bootstrap

No comments:

Post a Comment