So, you have heard of garbage collection and you roughly know that it is mainly for the stuff that gets allocated on the heap. But what is heap, really?
When a process is created, the OS will allocate memory for it, which we call process' virtual address space (VAS). The VAS has different sections where OS stores process' code (instructions), initialized/uninitialized data, stack etc. The stack will grow and shrink when you call or return from functions.

The heap on the other hand will grow and shrink as you wish, at the beginning it's just empty. You can use the system calls like brk(2), sbrk(2) and mmap(2) to request additional memory from the OS, which will expand the heap. But it is you who will be responsible to manage that free space you just got from the OS. The library functions such as malloc does that by maintaining free-list (usually a linked list), which stores pointers to places where you have unused memory. And calling free function will add previously allocated memory back to the free-list.