continually updating client from server

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • matt

    continually updating client from server

    Platform: Windows 2000, IE6, msxml 4
    Language: Javascript, client-side

    <Problem>: I'm using the xmldom.load() function to load a .xml file from a
    remote server. But i require to constantly poll the server as the data is
    updated. Say for example, in second 1 I pull down the last appended node, in
    second 2, I appended a new node using xml.save server-side (asp.net), so in
    second 3 I need to detect that a new node has been appended and pull it
    down - I do this by using a setInterval(... load(), 1000).
    Now in theory - and in fact practice - this works, and I've got a simple
    system working to continually update the client, but my problem is this:
    after a number of pollings of the server the client slows down to a creep -
    and eventually becomes useless. In my mind I'm either overflowing the stack,
    as on each new .load() its just appending to the memory, or javascripts
    garbage collection isnt efficient enought to cope (which effectively results
    in the same thing).

    <Question>: What techniques does anyone suggest to clear out the memory (I
    know Javascript doesn't support anything close to memory management), but by
    not explicitly declaring my varibles, would I be able to use the "delete"
    operator?

    <Question>: Or can someone suggest a more elegant way to poll the server for
    updates? I was thinking about using ondataavailable , but this is only used
    for objects being loaded, rather than objects that are effectively in a
    continual state of flux.

    I would post code, but its currently under copyright.

    matt
  • Martin Honnen

    #2
    Re: continually updating client from server



    matt wrote:
    [color=blue]
    > Platform: Windows 2000, IE6, msxml 4
    > Language: Javascript, client-side
    >
    > <Problem>: I'm using the xmldom.load() function to load a .xml file from a
    > remote server. But i require to constantly poll the server as the data is
    > updated. Say for example, in second 1 I pull down the last appended node, in
    > second 2, I appended a new node using xml.save server-side (asp.net), so in
    > second 3 I need to detect that a new node has been appended and pull it
    > down - I do this by using a setInterval(... load(), 1000).
    > Now in theory - and in fact practice - this works, and I've got a simple
    > system working to continually update the client, but my problem is this:
    > after a number of pollings of the server the client slows down to a creep -
    > and eventually becomes useless. In my mind I'm either overflowing the stack,
    > as on each new .load() its just appending to the memory, or javascripts
    > garbage collection isnt efficient enought to cope (which effectively results
    > in the same thing).[/color]

    How are you loading the XML, synchronously or asynchronously? ? Consider
    to use asynchronous loading
    xmlDocument.asy nc = true;
    xmlDocument.loa d('url')
    otherwise the load attempts to indeed block the browser
    --

    Martin Honnen


    Comment

    • matt

      #3
      Re: continually updating client from server

      <Extension question>: So I've definately narrowed it down to the setInterval
      call (I tried changing the async mode, and it didnt make any difference), so
      now my question is this: is there a more memory efficient method of
      constantly polling the server? I understand there's a number of ways to call
      a function a number of times, including using an eventHandler, but will that
      still raise the same problems? Is there ANY way in which I can reduce the
      load.

      matt

      Comment

      Working...