Imagine, I build a complex interface using jQuery/AJAX and want the application with this interface to be open during all day long. It deals heavily with AJAX, builds its elements, removes others, changes positions and sizes etc. How likely are memory leaks or browser lags with this scenario? How do I better deal with data and code to avoid overuse of memory? Are there any issues from the browser side I can face?
Imagine, I build a complex interface using jQuery/AJAX and want the application with this
Share
jQuery itself does a fairly good job at cleaning up after itself for items bound in events, etc. However, it’s still easy to leak events, etc by destroying objects outside of jQuery. For instance:
the above code wipes out the links that were in the div, but since jQuery doesn’t know it it doesn’t release the function from its internal data store of events and the function leaks.
You can also easily leak with any of the existing leak patterns, of which there are many: circular references, etc. Many of which are caused by closures.
google “javascript leak patterns” for info.