In article <11**********************@f14g2000cwb.googlegroups .com>,
<ra***********@gmail.com> wrote:
Is the Root Cause of the Memory corruption is the Memory leak, ??
No, almost never.
suppose If in the code there is Memory leak, Do this may lead to the
Memory Corruption while executing the program ?
No.
In nut shell, what is/are the realtion/s between the Memory Leak and
Memory Corruption.
Memory corruption is usually writing into memory you do not
own. That might be because you ran over the beginning
or end of an array, or because you free()'d an already
free()'d pointer, or because you used a pointer that
you did not initialize, or because you had an incompatability
with parameter passing and are taking non-pointer data
and treating it as a pointer, or it could be from trying
to write through a NULL pointer... or through other methods
involving various undefined or prohibitted pointer behaviours.
When you have memory corruption, it is common that you corrupt
the information that the system is using to keep track of
allocated memory. That corruption might not show up immediately,
but if you have a memory leak then sooner or later that internal
information is likely to be needed -- whereas without a memory
leak, you just might not happen to read that portion of memory.
There is not, in other words, a strong connection between
memory leaks and memory corruption.
There is, though, a fairly strong connection between memory
leaks, running out of memory (because it all leaked away),
and not having been careful to check the result of every
memory allocation, and thus ending up with a NULL pointer that
one thought was initialized.
--
"[...] it's all part of one's right to be publicly stupid." -- Dave Smey