Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: memory leak??

  1. #1
    New to the CF scene
    Join Date
    Mar 2004
    Thanked 0 Times in 0 Posts

    memory leak??

    Hi everyone,

    Really hoping someone can help me with a javascript / memory problem I'm having.

    Environment is Win7, MSIE v8.0.

    I have a pretty simple test function for this problem:

    function go() {
          // create giant text string in variable 'bill' then set 'bill' to null - store inside variable called 'test' as text.
          var test = "bill = 'blah blah blah blah blah (repeat blah about a thousand times or so for file size)'; bill = null;";
          // execute text inside variable 'test' as code
          var tester = new Function(test);
          // destroy function used to execute string as code
          tester = null;
    now, when you trigger the function go() through a button (ie <button onclick='go();'>go</button>) you can watch the memory usage in taskmgr go up every time you click the button (for me it goes up about 3MB every time go() is called - but that will depend on how many blah's you have).

    I have tried replacing var tester = new Function(test); with the eval() command... Same problem.

    It would appear the function is creating (storing in memory) a new instance every time its called ... What am I doing wrong here?? How do I stop the memory increasing every time i try to execute the string 'test' as script?

    Checked this code in Chrome and Firefox - they don't seem to have any memory issues running this code - its only a IE issue (*sigh*). That doesnt help me as the problem relates to a client's HTA application (can't switch off IE engine).

    Huge thanks in advance!

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,573 Times in 2,551 Posts
    Have a look at


    It is your responsibility to die() if necessary….. - PHP Manual


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts