views:

372

answers:

2

Background: I'm currently working on an intranet site that makes use of the MochaUI library (working from the virtual desktop demo). I'm using Mootools 1.2.4 and MochaUI 0.9.7. The windows that are opened in my "virtual desktop" implementation load their content via iframes. Some of the loaded pages are pretty hefty in terms of css and scripting, so it's important that Window objects are adequately garbage collected when the user closes a window. This is ostensibly taken care of by the library (it does do a fair job when using Firefox).

Update The originally posted question had become overly long from subsequent edits/updates. The title wasn't accurate anymore, so I changed that as well. Also, see my answer below for a partial solution.

Here are the essential points:

  1. Chrome goofs up like so:

    • Chrome fails to free up memory allocated for MochaUI window objects when they're closed. Instead, Chrome's memory usage freezes (literally) at the level reached after the window has finished loading its iframe content, setting a lower bound on memory usage until the page is refreshed.
    • Memory used by the process continues to increase with subsequent window openings/closings. Eventually, some type of cap is reached, and the memory usage stops climbing as steeply/starts to oscillate instead of jump up dramatically.
    • This problem is most apparent when the windows in question are loading fairly hefty (memory-wise) iframe content. The window I'm using for all testing purposes loads a 580 kb page (uncached) in its iframe.
  2. Strangely enough, the expected garbage collection does take place, when

    • the browser is subsequently minimized
    • another tab is opened in the same browser window
    • a Memory Timeline is being recorded in Developer Tools. (comedy option)
    • Does this behavior suggest any possible approaches to solving #1?
+6  A: 

I'm not sure if this was tested in Windows, but if so keep in mind that whenever you minimize a window in windows it moves all data to the pagefile. When opening the window again it won't move the memory blocks back unless the program tries to access them, and thus any garbage stays in the pagefile but isn't actually collected.

If you'd automate it, it would not only slow the program down it would also not help with any memory issues.

Doggett
All the machines on the intranet that will be using the site run Windows XP, I believe. I hadn't considered that issue with the pagefile, though automating/tricking Chrome to its Minimized state (somehow, to whatever effect) was a long-shot concept...Ideally, I would find some way to change my javascript code so that Chrome recognizes the objects to be garbage collected as per usual.
freenatec
Have you tried setting the variables/objects to null once you are done with them?
Lime
As far as I grasp the library's functions that handle the window-closing behavior, it appears to set all the relevant objects to null when a window closes. The content loaded in the windows (in iframes) is more my own code, and it's somewhat messy and probably contributes to leaks...however, I should note that Firefox clearly frees up memory when windows close (to the tune of 3-5 MB over about 5 seconds). The memory usage of the relevant Chrome process, on the other hand, stays static when windows are closed, and the only thing that makes it decrease is minimizing the browser.
freenatec