garbage is when you initialize a new pointer and dont delete it when you're done using it
Garbage varies from OS to OS
on few there are hardened runtimes which zero memory where possible during allocation, free, and resource reclaim in order to prevent attacks that take advantage of left over memory that could hold secrets of some kind that they should not know about, say passwords left over in memory
On most, memory will be left uninitialized as it is reused by programs, uninitialized memory may contain garbage
This garbage data may have been useful data for a previous program that was running (P1 exits which causes 0x56 to be released back to the system, P2 allocates the free 0x56)
This garbage data may have also been useful data for a running program that has since freed that memory (P1 frees 0x56, P2 allocates the free 0x56)
Do note that most garbage is from malloc/new since they recycle freed memory globally by all programs
In most cases when a program starts up it will be allocated memory for its main stack
eg the main thread, usually a very generous 8 MB depending on OS and thread implementation
normal threads will have a much smaller stack unless explicitly requested a larger stack upon thread creation, as they do not normally need to run a full program and manage lots of stack variables and stuff since all that is shared with the main thread via address space sharing (differs from OS to OS)
this memory may or may not have been previously used by another program that has since freed that memory
Eg on a freshly booted system it is likely the entire RAM is filled with zeros and most new programs will receive zeroed memory until recycling kicks in (assuming when RAM powers off its entire contents is effectively zeroed due to it not retaining any data)
Tho the kernel may also unintentionally cause new programs to get garbage when fresh booted even if no programs have started yet and it is only the kernel init process running (the kernel itself (or sysd, can't remember) is usually init with pid 0, OS dependant tho)
Also note that if a process or libc implementation zeros it's allocated memory address 0x56 before freeing it then another program allocating the same memory address will receive zeroed memory since 0x56 was zeroed before it was freed
Tho this zeroing of memory should NOT be relied on and callers should use calloc to unsure zerod memory if memory will be partially overridden (calloc is usually much faster than malloc + memset) or malloc/new if all memory will be FULLY overwritten and not read before it is overwritten