Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
Garbage, in the context of computers, is used to refer to any unwanted or unused data occupying memory space. Unallocated memory must be free of garbage values before allocating them, as the presence of garbage values may cause security issues and exceptional conditions.
Under normal usage, the word garbage refers to any waste product or something that is no more useful. Just as garbage does not occur naturally in the real world, garbage in the computing world is also created by programmers and their style of writing programs.
In computing terms it may refer to either of two meanings:
When users write programs, the presence of garbage values must be addressed as these can cause runtime issues during program execution. Programming languages like C and C++ do not provide any automatic garbage management features, and hence when writing programs in these languages, the programmer must free all the allocated memory before the associated objects are destroyed. Programming languages like Java and .NET framework languages provide automatic garbage collection features, freeing the programmer from the memory deallocation issues.
When manual memory allocation and freeing of memory is not done properly, human errors may cause bugs or serious threats to system security. When the programmer fails to free the memory after its use, memory leaks may occur and there is also a chance of system crashes due to dangling pointers.