Dangling Pointers/ Memory Leak definitions... - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Dangling Pointers/ Memory Leak definitions... (/thread-4947.html)
Dangling Pointers/ Memory Leak definitions... - WhatMeWorry - Oct 3, 2005 10:30 AM
Let me see if I have this (in my own words) correct?
A Dangling Pointer is when dynamic memory has been deallocated
(free/delete) but there is one or more Pointers still pointing to it.
A Memory Leak is when all the Pointers to dynamic memory have
been lost. So the memory can neither be accessed or deallocated.
So is the rule of thumb this: When the last pointer to dynamic memory
is about to be "lost", deallocate the memory using that pointer. When
memory is deallocated, make sure all pointers to it are NULLed.
Have I Left out anything? Any variations of the above?
Dangling Pointers/ Memory Leak definitions... - OneSadCookie - Oct 3, 2005 10:43 AM
you'll find that most of the time, most people won't NULL pointers to stuff they've just deallocated, usually either because that pointer is itself about to be deallocated, or because they're just about to assign a new value to it. It'll never hurt to do so though