Javascript memory leaks – code cleanup

MockupTiger is going through some rigorous functional and performance testing. During the performance testing we found that after several forced refreshes of the pages, Firefox kept on creeping up the memory usage.

When using the Mockups, there is no need to refresh the page or the application. It is all AJAX based so the pages are pulled in the background. Irrespective of the usage, this was one test we wanted it to pass in order to provide a clean exit from the browser.

When you close the browser or the tab, the application anyway releases all the memory through the javascript garbage collection.

But when you keep refreshing the application main page, it kept leaking memory. This problem lead to some other bugs within the application and the browsers functionality. For e.g Why Firefox calls window.unload twice when you refresh a page or close the tab?

In our window.unload call we nullify all the objects and the DOM objects that contain the widgets. This eliminated the memory leak issue but we also had to provide a tweak for Firefox so that the cleanup is done only once.

To nullify the javascript object simply call Object=null and for the dom, a simple call to jquery $("center_box").remove() does the trick.

We had some intermix of javascript in the main html body and since we are planning to use Google closure as the javascript police, we are in the process of segmenting the files and deciding what to compress.

I hope we should have an internal stable version of compressed javascript code within next few days.

Related posts:

  1. PHP API for member database

Get MockupTiger downloaded on your PC

Posted in Other

Would you like to build your application?

Start by sketching your idea into a wireframe in few clicks