Js about the mechanisms of memory

js memory space is divided into: Heap (heap), stack (stack), pool (also generally classified as stack). Which store complex object heap, stack variable storage pool to store constants.

JS in the underlying data type, these values have a fixed size, are often stored in the stack memory (except closure), storage space is allocated automatically by the system. We can directly manipulate the value stored in the stack memory space, so the basic data types are accessed by value and use the data stored in the stack memory stack data structure similar to the data structure, follows the principle of LIFO. Basic data Number String Null Undefined Boolean types: .

JS environment allocated memory generally follows the life cycle:

  1. Memory allocation: When we declare variables, functions, objects, the system will automatically allocate memory for them
  2. Memory usage: the read-write memory, that is, the use of variables, functions, etc.
  3. Memory Recovery: After use, automatically reclaim unused memory by the garbage collection mechanism

Guess you like

Origin www.cnblogs.com/zyq122/p/11271173.html