Memory leaks

Discussion in 'Javascript' started by Laser Lips, Jul 31, 2008.

  1. Laser Lips

    Laser Lips Guest

    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
    Laser Lips, Jul 31, 2008
    #1
    1. Advertising

  2. Laser Lips wrote:

    > 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.

    --
    Bart
    Bart Van der Donck, Jul 31, 2008
    #2
    1. Advertising

  3. Laser Lips

    Laser Lips Guest

    On Jul 31, 4:56 pm, Bart Van der Donck <> wrote:
    > Laser Lips wrote:
    > > 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.
    >
    > --
    > Bart


    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
    Laser Lips, Aug 1, 2008
    #3
  4. Laser Lips wrote:

    > ...
    > 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

    --
    Bart
    Bart Van der Donck, Aug 2, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ASP.Confused

    ASP.NET - Detecting memory leaks

    ASP.Confused, Jul 16, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,721
    Marina
    Jul 16, 2004
  2. =?Utf-8?B?RnJhbmsxMjEz?=

    Memory Leaks in ASP.NET

    =?Utf-8?B?RnJhbmsxMjEz?=, Mar 4, 2005, in forum: ASP .Net
    Replies:
    12
    Views:
    13,803
  3. James Hunter Ross

    Our memory leaks?

    James Hunter Ross, Oct 20, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    759
    Bruce Barker
    Oct 20, 2005
  4. Novice
    Replies:
    28
    Views:
    5,049
    Jon Skeet
    Jul 22, 2003
  5. Replies:
    4
    Views:
    101
Loading...

Share This Page