Memory Leaks in JavaScript? 
Author Message
 Memory Leaks in JavaScript?

howdy--

<quote from="Peter Torr(MS)">

JScript is a garbage-collected language (as is JScript.NET, although
they
use different GC technologies), and so you can't force the release of an
object under normal circumstances. Nevertheless, if you set all
references
to the object to null and then call the (undocumented) CollectGarbage()
method, JScript should release the object.

The reason CollectGarbage is undocumented is because you shouldn't use
it.
Is there a reason why you need to force the reference to disappear, or
are
you just worried about performance (in which case... don't)?

</quote>

More specific to your question, arrays in JScript are sparse and eat
memory as you fill them (they're just regular JS objects).

As for memory leaks: none that I've (ever?) experienced with JScript.
That's a huge part of the beauty, and should be last in your list of
culprits for memory leakage.

If you do have an example of a memory-leaking script, post it.

T


Is it needful to delete objects created with 'new' or does JavaScript
manage it's memory itself? If so, could you please tell me how to delete
an object. I couldn't find a function in JavaScript that could manage
that. For example: Thanks a lot with best regards
Markus ------------------------------------------------------------ Get
your FREE web-based e-mail and newsgroup access at:
http://www.*-*-*.com/ Create a new mailbox, or access your existing
IMAP4 or POP3 mailbox from anywhere with just a web
browser. ------------------------------------------------------------



Sun, 23 Nov 2003 01:05:13 GMT  
 Memory Leaks in JavaScript?

Quote:
> If you do have an example of a memory-leaking script, post it.

  I do not have memory-leaking-script in that sense....

  However it is very fun to see how that js-software eats by Netscape the
amount of free memory.
  (watched with sysmon.exe) about 0.7-1 megabyte per second...

  There is a huge  button very below. Click on it. Have phun...
  The lighter alternative might be to click on that ugly face ( of mine )
;-]
  MM's "what the web can do." JS-ABC: http://my.tele2.ee/cadorsoft

p.s.
  Yesterday I downloaded Opera5.11    And it works there too as also by
previous
  Opera browser releases since version 3.21 ... :-))

--
MM anno MM(I) aus Estland;
a bit out of date js&dhtml&Co linkspage:
http://my.tele2.ee/cadorsoft/links2PROJECT6.htm



Mon, 24 Nov 2003 08:43:53 GMT  
 Memory Leaks in JavaScript?
I have come across one type of memory leak in JScript in IE5. I guess this is not
a 'pure' JScript problem because it invloves the DHTML object model.

The following code snippet should demonstrate the problem for you:

<SCRIPT>
    // Create a big object
    var a = new Array();
    for (var i=1; i<15000; i++)
    {
        a[i] = "TestingTestingTestingTestingTesting";
    }

    // Create a DHTML element
    document.writeln ("<DIV id='Test'>testing</DIV>");

    // Make a circular reference between the big object and the DHTML element
    a[0] = document.all["Test"];
    a[0].Object = a;
</SCRIPT>

This should add about 1MB of memory usage every time you refresh the page!

Quote:
-----Original Message-----

howdy--

<quote from="Peter Torr(MS)">

JScript is a garbage-collected language (as is JScript.NET, although
they
use different GC technologies), and so you can't force the release of an
object under normal circumstances. Nevertheless, if you set all
references
to the object to null and then call the (undocumented) CollectGarbage()
method, JScript should release the object.

The reason CollectGarbage is undocumented is because you shouldn't use
it.
Is there a reason why you need to force the reference to disappear, or
are
you just worried about performance (in which case... don't)?

</quote>

More specific to your question, arrays in JScript are sparse and eat
memory as you fill them (they're just regular JS objects).

As for memory leaks: none that I've (ever?) experienced with JScript.
That's a huge part of the beauty, and should be last in your list of
culprits for memory leakage.

If you do have an example of a memory-leaking script, post it.

T



Is it needful to delete objects created with 'new' or does JavaScript
manage it's memory itself? If so, could you please tell me how to delete
an object. I couldn't find a function in JavaScript that could manage
that. For example: Thanks a lot with best regards
Markus ------------------------------------------------------------ Get
your FREE web-based e-mail and newsgroup access at:
http://MailAndNews.com Create a new mailbox, or access your existing
IMAP4 or POP3 mailbox from anywhere with just a web
browser. ------------------------------------------------------------

.



Sat, 06 Dec 2003 21:41:34 GMT  
 Memory Leaks in JavaScript?
I have come across one type of memory leak in JScript in IE5. I guess this is not
a 'pure' JScript problem because it invloves the DHTML object model.

The following code snippet should demonstrate the problem for you:

<TEXTAREA rows='15' cols='75'>
<SCRIPT>
    // Create a big object
    var a = new Array();
    for (var i=1; i<15000; i++)
    {
        a[i] = "TestingTestingTestingTestingTesting";
    }

    // Create a DHTML element
    document.writeln ("<DIV id='Test'>testing</DIV>");

    // Make a circular reference between the big object and the DHTML element
    a[0] = document.all["Test"];
    a[0].Object = a;
</SCRIPT>
</TEXTAREA>

Quote:
-----Original Message-----

howdy--

<quote from="Peter Torr(MS)">

JScript is a garbage-collected language (as is JScript.NET, although
they
use different GC technologies), and so you can't force the release of an
object under normal circumstances. Nevertheless, if you set all
references
to the object to null and then call the (undocumented) CollectGarbage()
method, JScript should release the object.

The reason CollectGarbage is undocumented is because you shouldn't use
it.
Is there a reason why you need to force the reference to disappear, or
are
you just worried about performance (in which case... don't)?

</quote>

More specific to your question, arrays in JScript are sparse and eat
memory as you fill them (they're just regular JS objects).

As for memory leaks: none that I've (ever?) experienced with JScript.
That's a huge part of the beauty, and should be last in your list of
culprits for memory leakage.

If you do have an example of a memory-leaking script, post it.

T



Is it needful to delete objects created with 'new' or does JavaScript
manage it's memory itself? If so, could you please tell me how to delete
an object. I couldn't find a function in JavaScript that could manage
that. For example: Thanks a lot with best regards
Markus ------------------------------------------------------------ Get
your FREE web-based e-mail and newsgroup access at:
http://MailAndNews.com Create a new mailbox, or access your existing
IMAP4 or POP3 mailbox from anywhere with just a web
browser. ------------------------------------------------------------

.



Sat, 06 Dec 2003 21:57:45 GMT  
 Memory Leaks in JavaScript?
I followed this, then continued normal web browsing for a while and noted that my memory use
eventually dropped back down.

Quote:

> I have come across one type of memory leak in JScript in IE5. I guess this is not
> a 'pure' JScript problem because it invloves the DHTML object model.

> The following code snippet should demonstrate the problem for you:

[snip]

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use of this email address
implies consent to these terms.



Sun, 07 Dec 2003 04:09:49 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Huge Memory Leak if you use JavaScript in IE4

2. pscal memory leaks

3. bizarre memory leak in IISx

4. array memory leak HELP!

5. JScript memory leak

6. Behavior memory leak, part 2

7. Memory Leak in JScript Engine?

8. VBScript Function causes memory leak!

9. memory leak?

10. No error reported and memory leak if error occurs in Class_Terminate

11. Possible memory leak - error '800a0007'

12. Database not available causing memory leak in vbscript

 

 
Powered by phpBB® Forum Software