# 05. Garbage Collection

### What is Garbage Collection?

Whenever we are working with heap memory, we as programmer are responsible for managing memory. Managing heap memory has traditionally been difficult task. This is the case with traditional programming languages like C,C++. &#x20;

> Microsoft: 70 percent of all security bugs are memory safety issues - ZDNet

source : <https://www.zdnet.com/article/microsoft-70-percent-of-all-security-bugs-are-memory-safety-issues/>

Since memory management has been tedious tasks, various programming languages have evolved to provide these features. C#, Java, Python all provides memory management as a feature so that programmer has no longer to worry about memory management.

The feature of language to manage memory for programmer is called Garbage collection. Garbage collection can be thought as a side running program that manages heap allocation and de-allocation.

### Blog Posts

{% embed url="<https://www.ardanlabs.com/blog/2018/12/garbage-collection-in-go-part1-semantics.html>" %}

{% embed url="<https://www.ardanlabs.com/blog/2019/05/garbage-collection-in-go-part2-gctraces.html>" %}

{% embed url="<https://www.ardanlabs.com/blog/2019/07/garbage-collection-in-go-part3-gcpacing.html>" %}

{% embed url="<https://blog.golang.org/ismmkeynote>" %}

### Video Resources

{% embed url="<https://www.youtube.com/watch?v=q4HoWwdZUHs>" %}
How to be sympathetic with the Go garbage collector, regardless of the current implementation or how it changes in the future
{% endembed %}

{% embed url="<https://www.youtube.com/watch?v=bMujSVMarqY>" %}
Golang UK Conference 2017 | Will Sewell & Jim Fisher - Golang's Realtime GC in Theory and Practice
{% endembed %}


---

# 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://book.codewithgo.com/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.
