# Garbage Collection

Garbage Collection is a form of **automatic memory management**, used by (often) higher-level programming languages to remove the need for complicated manual memory management. As a result, manual memory management is **not implemented**, and the developer relies on the garbage collection to handle memory, preventing bugs such as [UAFs](/notes/binexp/heap/use-after-free.md) or [Double-Frees](/notes/binexp/heap/double-free.md).

The two main types are [Tracing Garbage Collection](/notes/binexp/memory-safety/garbage-collection/tracing-garbage-collection.md) (which is often just referred to as "Garbage Collection") and [Automatic Reference Counting](/notes/binexp/memory-safety/garbage-collection/automatic-reference-counting.md).


---

# Agent Instructions: 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://ir0nstone.gitbook.io/notes/binexp/memory-safety/garbage-collection.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.
