Next page | Contents page |

Garbage collection

The interpreter (eg, browser) reclaims memory for variables when they go out of scope (eg, at the end of a function) or if there is no longer any variable containing a reference to the object or array. The technical term for this is garbage collection.

You cannot guarantee when this will happen.

You don't explicitly delete objects to free up memory but if you can assign all of an object's references to null (a = null;) garbage collection will remove it at some stage.

Next page | Contents page |