Is garbage collection in programming language used for collecting heap memory nothing else?

1

The garbage collection to recycle object that is no longer used is to deallocate heap memory? Does Memory leak represent no enough heap memory space for the program to run? So what we normally say "out of memory" refers to "out of run time memory" which is "heap memory"?

FunctionBlock

Posted 2018-03-30T05:55:45.983

Reputation: 81

Question was closed 2018-03-30T07:20:37.557

Answers

0

Garbage collection usually indeed refers to the heap memory.

Note that memory leaks and out of memory errors are not synonymous. A memory leak is a situation where some chunk of allocated memory (e.g., an object in a OO language) is no longer needed, but for some reason cannot be deallocated/collected (e.g., the programmer forgot to clear some reference to it).
You can have a memory leak that does not cause an out of memory error (if the leak is sufficiently small), and you can get such an error without having a memory leak (if you legitimately try to allocate more memory than's available to the process).

Mureinik

Posted 2018-03-30T05:55:45.983

Reputation: 3 521