Main Menu

Categories

Subscribe

JavaScript Garbage Collection

March 18th, 2009

Every time a JavaScript program creates a string, array or object, the JavaScript interpreter allocates memory to store one of the three. When memory is dynamically allocated like this, it must eventually be freed up.

With Programming languages like C and C++, the programmer must manually destroy the objects when they are no longer needed.

JavaScript is different, instead of manually freeing up memory by the programmer, It uses a technique called garbage Collection. The JavaScript interpreter can detect when an object will never be used again in the program and frees up the allocated memory used by that object.

No Comments

Leave a Reply