Memory leaks in SharePoint hosted single page app

Hi Everybody,

I am developing a SharePoint 2013 hosted app and use REST and/or CSOM queries to retrieve items from lists and use them on a single page app (SAP). Because the page is not refreshing, big amounts of memory leaks that otherwise wouldn't be a problem become a huge issue and the app reaches its maximum allowed memory and crashes. I use IE Developer Tools to monitor the memory and compare snapshots. Looks like jQuery is caching the data that I put on the view, including the various handlers, and every time I change the data on my view as much as 7 MB is retained. I am attaching an image of the details and where I traced a circular reference on a function that is abbreviated. I am quite lost about what I can do here. Is there a magical way to prevent (if this is even relevant here) jQuery from caching some or all of the data? Any idea or info is much appreciated.



May 25th, 2015 2:11pm

Hi Jerry,

Refreshing the page always works, in this app we are trying to avoid refreshing the page. BTW have you personally used or heard anything SPCAF tool? Thank you!

Also, do you think in the html fragment below the onclick="SortHtmlTable(1)" will create a memory leak?
<a onclick="SortHtmlTable(1);" href="javascript:;"><input id="someID" type="submit" class="someButton" value="Date" /></a>


  • Edited by d16tr Tuesday, May 26, 2015 3:55 PM
Free Windows Admin Tool Kit Click here and download it now
May 26th, 2015 3:35pm

Hi Bhism,

- I do have a set of global variables but I make sure I nullify them every time before I reuse them.

- I do use IFFE model but try to not expose too many variables inside the closure.

- I am using document.ready() in a few places.

One thing I forgot to mention is I use angularjs for routing only, but I don't see it on the IE Developers Tool memory snapshots. BTW have you personally used or heard anything SPCAF tool? Thank you!

May 26th, 2015 3:41pm

Hi,

The SPCAF is a tool analyse the WSP code for SharePoint.

JavaScript memory leak usually happens when the browser for some reason doesnt release memory from objects which are not needed any more.

In your function,if there are some variable or object not released, then it will cause the memory leak.

Here is a detailed article for your reference:

JavaScript Memory leaks

Thanks

Best Regards

Free Windows Admin Tool Kit Click here and download it now
June 1st, 2015 9:52pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics