I've noticed significant memory leaks in an app I'm currently developing. Despite its lack of complexity, the app requests approximately 40kb of JSON data from the server every 15 seconds. This data is then used to generate a table on the page. As the data is usually new, it's more cost-effective to redraw the table each time. The table has around 30 lines, with about 5 events attached per line. To update the table, I utilize jQuery's .html() method to replace the existing content with the new data. This triggers jQuery's cleanup functions to detach any previous events associated with the elements being replaced. Additionally, I make sure to delete large HTML variables once they are inserted into the DOM using delete my_var
.
I have attempted to identify and address circular references and lingering events, but I haven't delved deeply enough into debugging them. If anyone could provide guidance on optimizing performance for such resource-demanding applications, that would be greatly appreciated. Although I recently acquired "High Performance JavaScript" by Nicholas Zakas, I haven't had the chance to fully explore its insights yet.
For context, after running for approximately four hours, the app consumes around 420,000k of memory in Chrome, significantly more in Firefox or IE.
Any advice would be welcome!