app.data & memory management

10 views
Skip to first unread message

Rasmus

unread,
Oct 16, 2013, 10:59:34 AM10/16/13
to he...@googlegroups.com
Hi,

Is there any way to delete data from app.data and have the allocated memory released? The docs say app.data is not grabage collected and we ran into a situation where (after running for a couple of days) the server's Java heap ran out of space. We suspect our way of using app.data could be leaking memory.

The following pseudocode demonstrates roughly how we are using app.data. The idea is to store some data in app.data that may or may not be requested by the user later. The stored entries are time-stamped and we try to purge entries that are older than a certain limit:

1. HTTP request arrives

...
app.data.cache = [];  // initialize cache
var data = <some data>;  // data we want to access later
var key = generateUniqueKey();
app.data.cache[key] = data;
for (key in app.data.cache) {            // this loop is supposed to purge expired items
  if (isExpired(app.data.cache[key])) {
    delete app.data.cache[key];
  }
}
...

2. HTTP response is sent with key

3. Client wants to access stored data

4. HTTP request with previously given key as a parameter arrives

...
var returnData = app.data.cache[key];
...

5. HTTP response with previously returned data is sent

Thanks!

Simon Oberhammer

unread,
Oct 22, 2013, 4:46:39 AM10/22/13
to he...@googlegroups.com
Hi,
as I understand the docs, they mean to say "data stored in app.data does not vanish between requests" (unlike most other global properties) but I would be surprised - and it's not the behavior we see - if app.data properties would not be garbage collected if de-referenced.

i hope that helps.. probably not, sorry :)

 simon
Reply all
Reply to author
Forward
0 new messages