> For the complete documentation index, see [llms.txt](https://sekin.gitbook.io/myjs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sekin.gitbook.io/myjs/nei-cun-de-na-xie-shi/la-ji-hui-shou-ji-zhi.md).

# 垃圾回收机制-GC

#### 原文地址：[http://web.jobbole.com/92652](http://web.jobbole.com/92652/)

#### Javascript是如何工作的： Engine， Runtime 和 Call Stack的概述：<https://www.jianshu.com/p/458930ff4778>

## 无论哪种语言内存的生命周期分三个：

* > **内存的分配**\
  > 系统分配内存，让程序来使用。
* > **内存的使用**\
  > 就是对分配的内存的使用，通过与其对应的变量，进行读写操作。
* > **内存的释放**\
  > 不用的时候就释放内存，等候重新分配给变量。

## **什么是内存？**

在电脑的硬件中，内存包括了很多的触发电路，这些触发电路里又有很多的晶体管，每一个晶体管里可以存储1位数据。

触发器通过唯一的地址来读写和覆盖这些数据。

程序里所有的变量。数据，代码，已及操作系统都保存在内存中。

**变量和内存的联系：实时上我们在声明一个变量的时候，比如 var n =0; 这个n 会被在内部翻译成一个内存的地址,类似** “memory address 4127963”的语句。&#x20;

### 词法作用域


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sekin.gitbook.io/myjs/nei-cun-de-na-xie-shi/la-ji-hui-shou-ji-zhi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
