dcsimg
How to improve Javascript to avoid memory leaks.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Manju_k
Posted On:   Tuesday, April 22, 2003 06:47 AM

Can someone give a couple of general tips to improve Javascript code to avoid memory leaks. My code uses a lot of arrays.
Thanks.

Re: How to improve Javascript to avoid memory leaks.

Posted By:   Benoit_Quintin  
Posted On:   Tuesday, April 22, 2003 12:16 PM

JavaScript is inherently unsafe, not strongly typed, and usually incurs poor performance on the client-side. And yet, it is the most used/implemented in web browser... The easiest way I know is to create pseudo-objects, and then create wrappers around them (which really isn't saying much since everything is pretty much within the public memory domain).

If you use lots of arrays, add getters and setters that contain your arrays, so you can have only one piece opf code to maintain, instead of copy/pasting array manipulation. Also, check the Array object.

I know that JavaScript 1.5 is supposed to have try/catch statements incorporated, but I have yet to use it...

Good luck.

About | Sitemap | Contact