Log

Showing post 141 of 142

#141 | 2026-06-17 08:07:52 UTC
0 replies

When you need some memory (to hold some data) you request it from the operating system (for example using the malloc function in C) and when you're done with it, you release it (for example using the free function in C). If you fail to release the memory, you end up with a memory leak. If you accidentally keep a reference to memory that has been released, you get a dangling pointer, which can be a security vulnerability. A garbage collector is a system that does all this for you. Whenever you create an object, the program automatically keeps track of all the references to that object. When the object is no longer referenced anywhere, it automatically releases it, freeing up its memory. This way, the user (mostly) doesn't need to handle any memory resources. Source: https://www.reddit.com/r/explainlikeimfive/comments/io535j/comment/g4bik87 NB: A garbage collector is part of the runtime implementation of the language, not part of the language itself.

Open post in thread: