Difference between dangling pointer and memory leak

后端 未结 8 1982
既然无缘
既然无缘 2020-12-12 08:44

I don\'t understand the difference between a dangling pointer and a memory leak. How are these two terms related?

8条回答
  •  悲哀的现实
    2020-12-12 09:20

    A pointer pointing to a memory location that has been deleted (or freed) is called dangling pointer. There are three different ways where Pointer acts as dangling pointer.

    1. De-allocation of memory
    2. Function Call
    3. Variable goes out of scope

    —— from https://www.geeksforgeeks.org/dangling-void-null-wild-pointers/

提交回复
热议问题