Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

How to check if memory to which pointer p points has been succesfully deallocated?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
131 views
Welcome To Ask or Share your Answers For Others

1 Answer

In few words: you can't.

Check out tools like Valgrind to help you debugging memory leaks issues.

Some other things you should consider:

  • Use smart pointers so that you don't have do think about memory management,
  • Set your pointers to 0 after you free them, so that a further delete has no effect,
  • Use standard classes (vector, ...) instead of rolling your own,
  • Finally, don't use pointers (actually you almost can)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...