www.thecareerplus.com
The CareerPlus
Home Technical Resources Programming Arrays and Pointers
Thursday 09th September 2010
 
 
What is a dangling pointer? What are reference counters with respect to pointers?

Discuss it!          



A pointer which points to an object that no longer exists. Its a pointer referring
to an area of memory that has been deallocated. Dereferencing such a pointer usually
produces garbage.
Using reference counters which keep track of how many pointers are pointing to this
memory location can prevent such issues. The reference counts are incremented when
a new pointer starts to point to the memory location and decremented when they no
longer need to point to that memory. When the reference count reaches zero, the memory
can be safely freed. Also, once freed, the corresponding pointer must be set to NULL.

Discuss it!          

CrackTheIntervew.NET
Advertisement
 
Top! Top!