Definition - What does Garbage mean?
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.
Techopedia explains Garbage
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:
- Anything that is unreadable or unviewable on the computer screen to a normal user may be perceived to be a garbage file or value. This may occur when the user is trying to open a corrupted file or a file of a format that is not supported by the system.
- From a programming point of view, the term garbage is used to point to unwanted data held by the primary memory. These data may have been stored in the memory by a previous program and is unwanted and unusable for the current program execution.
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.