Difference between memory overflow and memory leak

  • Out of memory means that when the program requests memory, there is not enough memory space for it to use. For example, if an integer is applied for, but the number that can only be stored by a long is stored for it, that is a memory overflow.

  • Memory leak Memory leak means that the program cannot release the memory space that has been applied after applying for memory. The harm of a memory leak can be ignored, but the accumulation of memory leaks has serious consequences. No matter how much memory, it will be occupied sooner or later.

Memory leak will eventually lead to out of memory!
For example, adding elements to ArryList infinitely without emptying the elements in time (memory leak), when the memory is not enough, memory overflow will occur.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324649728&siteId=291194637
Recommended