I’m having a problem that looks similar to what Duong reported a couple years ago here:
https://groups.google.com/d/msg/google-chrome-developer-tools/XKnjOCnJ69s/f29CSvLdUQgJ
I’m trying to develop some gadgets for Atlassian JIRA. JIRA uses gadgets based on some old web-gadget API (I think it was originally published by Google), in which each gadget is shown in an iframe on the “dashboard” page. While trying to make a script to reload the gadget iframes (to measure average times automatically) I noticed that there’s a memory leak somewhere that keeps a significant part of the old frame contents from being collected. (And, after a few dozen reloads, Chrome crashes, which led to my investigation.)
I tried to figure out what is keeping the old frames in memory, but I can’t figure it out. The “Window” objects belonging to the old frame remain (with distance “1”), but all references to them that I can see seem to be Chrome internals like “global in system / Context @....”, and nothing from the page itself.
I’ve done everything I could think of and/or find on the net, like running in an empty Chrome instance in incognito mode, and with a minimal gadget that doesn’t really contain anything except for whatever the JIRA framework adds to it, but I can’t seem to find what keeps the old frames into memory. I’m attaching a screenshot and a couple of heap dumps, hoping some Chrome wizard can read the entrails better than I.
The attached screenshot shows the bad window (the URL path for the iframe ends with gadgets/ifr), remaining on the heap even after the gadget is removed. The attached archive contains the two heap snapshots shown in the screenshot. What I did was:
1) prepared a dashboard containing a single empty gadget;
2) opened a new new Chrome window with an empty profile, and logged into the JIRA instance;
3) opened a new tab in the window, and pasted the URL to the prepared dashboard;
4) opened the console with Ctrl-Shift-J, cleared it, clicked on the Profiles tab, then recorded the first heap snapshot;
5) deleted the gadget using the dashboard button and waited a few seconds;
6) recorded the second heap snapshot.
As can be seen, there is still an instance of the Window object from the gadget iframe on the heap (and probably other stuff as well). I can’t figure out what is it that still has a reference to it on the page.
I’ve tried other things, they all seem to have similar results. Deleting the iframe element directly, either via the Element Browser or via the console, instead of step 5, causes pretty much the same results, or at least I can’t find the difference. Reloading the gadget, either via right-click or by triggering a reload from the console (e.g., window[0].location.reload()) leaves one old “window” object on the heap for each reload, they just seem accumulate and never go away as long as the top window doesn’t navigate away.