M Memory allocation (Definition) Memory allocation (Definition) (Geocities web hosting)
M Memory allocation (Definition) Memory allocation (Definition) The process of locating and allocating some memory to store a string or object. See also: Reference counting, Memory management Memory leak (Definition) The consumption of memory that is not recoverable. When the reference count for an object is zero, the object can be garbage collected. Also, because there are no references to it, you have no handle by which you can reach it, so if it isn’t garbage collected, it will waste the space it occupies. When that happens, you have a memory leak. Memory leaks typically happen in web-based JavaScript when you create and destroy a lot of strings in a loop. Concatenating many strings together and extending one string incrementally is a typical leak-producing technique. Garbage collection generally only happens in web browsers when the page is refreshed. delete, Garbage collection, Memory management, Object(), Option(), Reference counting, Variable, Window.setInterval(), Window.setTimeout() See also: Cross-references: Wrox Instant JavaScript page 29 Memory management (Definition) The process of organizing and keeping track of memory allocation and de-allocation. Memory management in compiled languages tends to be a primary concern of software developers. Because JavaScript is interpreted and is intended for use by designers as well as developers, a great deal of the complexity of memory management is hidden from view. It is still possible however to design a script that will consume large amounts of memory due to what is called a memory leak. A memory leak is when you allocate some storage and you don’t subsequently relinquish it and make it available to the system again. A prime example of a memory leak in the context of a JavaScript execution is the allocation of string data to String variables. When a new assignment is made, the old storage is unlinked from the variable and some new storage is allocated. This means that the storage management is far simpler because the strings tend to grow longer as new values are assigned. However, in a web browser, the discarded string values continue to sit around in memory until the page is refreshed. At that stage, all page local values are purged and the memory is freed. 1427