File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes $.getJSON leaking memory? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "$.getJSON leaking memory?" Watch "$.getJSON leaking memory?" New topic

$.getJSON leaking memory?

Mattias Andersson

Joined: Nov 17, 2010
Posts: 20
Hi, I'm a semi noob on javascript and have been dealing with JQuery for a little while now.
Im using $.getJSON and somehow I'm getting a memory leak of ~800 kb each request.
I'm using jquery-1.4.4.js and Struts 1.3.8.

In the following code snippet I have cut down the code to do nothing else than just calling my Struts actionclass.

In my Struts action class it looks like this

The leakage correlates to the size of "someData".
What am I doing wrong or missing here?

Sincerely, Mattias

It's better to be approximately right than exactly wrong.
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
What Browser?

Well the object has to be loaded into memory so there will be a memory increase.
Do you really need that full 800kb every request? Seems like a little extreme.
Do you set the data object to null after using it?


Mattias Andersson

Joined: Nov 17, 2010
Posts: 20
Both Firefox and IExplorer.

The amount of data is nothing more than a JSON array of JSONObjects.
The array is 5 long and the objects only contains a total of 4 attributes (boolean, boolean, string and int).

I can not understand how this can be 800kb.

I have tried to set the data to null (j = null). Nothing there.
I agree. Here's the link:
subject: $.getJSON leaking memory?
It's not a secret anymore!