Home >Web Front-end >JS Tutorial >stack memory in javascript
<--------Stack memory--------->
Commonly known as scope (global scope/private scope)
>Execution environment provided for js code (where js code is executed)
>Basic data introspection is stored directly in stack memory
<----- ---Heap memory--------->
Stores reference type values (equivalent to a storage warehouse)
>Objects store key-value pairs
>The function stores the code string
In the project, the less memory we have, the better the performance. We need to get rid of some useless memory
[Heap Memory】
var o = {}; The heap memory corresponding to the current object is occupied by variable o, and the heap memory cannot be destroyed
o = null; null is called a null object pointer (not Point to any heap memory), at this time the last heap memory is not occupied. Google Chrome will automatically release (destroy/recycle) the unoccupied heap memory during idle time. IE browser uses counting pointer method
【Stack Memory】
Under normal circumstances, function execution forms stack memory. After the function is executed, the browser will automatically release the formed stack memory; sometimes after execution is completed, the stack memory cannot be released.
The global scope is executed when the page is loaded and destroyed when the page is closed;
The above is the entire content of this article. I hope it will be helpful to everyone's learning. For more related content, please Follow PHP Chinese website!
Related recommendations:
js execution context variables, functions, this
The above is the detailed content of stack memory in javascript. For more information, please follow other related articles on the PHP Chinese website!