On Nov 11, 9:16 pm, saurabh singh saurab...@gmail.com wrote:
well that would be tough for the compiler to predict things that will
happen during run time.Its the job of garbage collector to do that.
well compiler cant predict what will happen at runtime.
On Fri, Nov 11, 2011 at 8:36
process heap is organized as chunk of free memory need not be
contiguous and during freeing what free() does is update it's book
keeping records and it's bins array so that next time if asked for new
space may return the same space however it doesn't wipe the freed data
but few run time directive
Not meaning any disrespect, this argument is about as wrong as it gets
in computer science.
Predicting when memory will be free in a running program at compile
time is called an _undecidable problem_. This means it's totally
impossible to write a C / C++ compiler that will produce an executable
nopes , they are not connected, it is just a chance you are getting
the same values and nothing is overwritten there: basically these are
DANGLING POINTERS . Now you should keep practising something like this
#define FREE(N) { free(N); N=NULL;}
to avoid such mistakes
On Nov 11, 3:41 pm, shady
ok, thanks.
why do we need to free the memory ?
Suppose i have a linked list of 1000 nodes and i make the head of it =
NULL, thus losing the whole list. Then compiler can look at other variables
and if this list has not been referenced anywhere else then it is useless,
thus will free the memory.
well that would be tough for the compiler to predict things that will
happen during run time.Its the job of garbage collector to do that.
On Fri, Nov 11, 2011 at 8:36 PM, shady sinv...@gmail.com wrote:
ok, thanks.
why do we need to free the memory ?
Suppose i have a linked list of 1000 nodes