Memory leaks

L

Laser Lips

Hi All. I'm building t a User Interface, which populates tables from
a database dynamically. It's using a technology called CACHE
(pronounced cashai, made by intersystem’s) to get the data form the
server. There is no page loading or refreshing. It's very much like
Ajax except there is no external file called, the server interprets
these calls right there on the page and returns the value, just like
calling a function. Interesting stuff.

Anyway, the data I get back is a huge JSON object, which sits in
memory; this doesn’t seem to pose a problem. I've got Windows Task
Manager open and I watch the little line graph move up and down.

I iterate through the JSON object to populate a table. There are only
about 1000 rows so it’s not many, but I am building the table
pragmatically using the DOM.

The first time I run this code it shoots through very quickly. Even
if a I press the button which causes it to run through the process
again, it still runs quickly. And even if I press it continuously, it
runs the same speed. But if I refresh the page by right clicking and
'refresh page' or 'F5' the code runs but slower. And every subsequent
page refresh and code run the code gets slower and slower. The CPU
usage line graph starts hitting the roof.

I would have thought that the page refresh would clear memory?
I'm trying to clear up after myself by setting certain variable to
null, but no change. If I close the browser down and start again, the
code runs quick again.

Why does the code run the same speed until I refresh the page. Are
new variables being instantiated each time I load the page and the old
ones staying alive?

Cheers All.
Graham
 
B

Bart Van der Donck

Laser said:
Hi All.  I'm building t a User Interface, which populates tables from
a database dynamically.  It's using a technology called CACHE
(pronounced cashai, made by intersystem’s) to get the data form the
server.  There is no page loading or refreshing.  It's very much like
Ajax except there is no external file called, the server interprets
these calls right there on the page and returns the value, just like
calling a function.  Interesting stuff.

Anyway, the data I get back is a huge JSON object, which sits in
memory; this doesn’t seem to pose a problem.  I've got Windows Task
Manager open and I watch the little line graph move up and down.

I iterate through the JSON object to populate a table.  There are only
about 1000 rows so it’s not many, but I am building the table
pragmatically using the DOM.

The first time I run this code it shoots through very quickly.  Even
if a I press the button which causes it to run through the process
again, it still runs quickly.  And even if I press it continuously, it
runs the same speed. But if I refresh the page by right clicking and
'refresh page' or 'F5' the code runs but slower.  And every subsequent
page refresh and code run the code gets slower and slower. The CPU
usage line graph starts hitting the roof.

I would have thought that the page refresh would clear memory?
I'm trying to clear up after myself by setting certain variable to
null, but no change.  If I close the browser down and start again, the
code runs quick again.

Why does the code run the same speed until I refresh the page.  Are
new variables being instantiated each time I load the page and the old
ones staying alive?

I think your observations are normal. F5 does refresh the page but not
the cache (use CTRL+F5 for that).

You claim that the huge JSON-object (which represents 1000 table rows)
is not that heavy; I tend to think differently about such amounts of
data on one web page. Once you want a solid program I think it's
unwise to invoke this kind of memory requirements. You cannot be sure
about the available memory of the client anyhow.
 
L

Laser Lips

I think your observations are normal. F5 does refresh the page but not
the cache (use CTRL+F5 for that).

You claim that the huge JSON-object (which represents 1000 table rows)
is not that heavy; I tend to think differently about such amounts of
data on one web page. Once you want a solid program I think it's
unwise to invoke this kind of memory requirements. You cannot be sure
about the available memory of the client anyhow.

Bart, your concern is correct, but how can I see how much memory is
being used by the JSON object. I dont think windows memory graph is
good enough.

I'll look around for some aps
 
B

Bart Van der Donck

Laser said:
...
Bart, your concern is correct, but how can I see how much memory is
being used by the JSON object.  I dont think windows memory graph is
good enough.

I don't have a real need for such extra tools, but that might be my
personal opinion. Common sense is probably more important; especially
when coding for unknown computers (which is the default execution
environment of javascript). And better play safe in case of doubt.

Car brands invest billions of Euros in Formula-One; not because
they're Ipso Facto sports fans, but because exploring the limits of
their technologies gives them a vast benefit for the daily production
work.

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top