473,320 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Memory Leak / Corruption

Dear All

Is the Root Cause of the Memory corruption is the Memory leak, ??
suppose If in the code there is Memory leak, Do this may lead to the
Memory Corruption while executing the program ?

In nut shell, what is/are the realtion/s between the Memory Leak and
Memory Corruption.

Juts Theoritical Assumtion below:

Ideally Memory leak, may not lead to the Memory Corruption.
Here I am talking, if Memory leak Is accepted.

Thnaks In Advance.
Ranjeet

Nov 15 '05 #1
8 3373
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
Nov 15 '05 #2
ra***********@gmail.com wrote:
Dear All

Is the Root Cause of the Memory corruption is the Memory leak, ??
No.
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.


A memory leak is when you no longer remember where memory you own is
located. This is very silly. Memory corruption is when you refer to memory
you don't own. This is even sillier.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
mail: rjh at above domain
Nov 15 '05 #3

ra***********@gmail.com wrote:
Dear All

Is the Root Cause of the Memory corruption is the Memory leak, ??
suppose If in the code there is Memory leak, Do this may lead to the
Memory Corruption while executing the program ?

In nut shell, what is/are the realtion/s between the Memory Leak and
Memory Corruption.

Juts Theoritical Assumtion below:

Ideally Memory leak, may not lead to the Memory Corruption.
Here I am talking, if Memory leak Is accepted.

Memory leak is a bug in your program where the memory is allocated
but not freed afterwards although it is never used again.
It has nothing to do with memory corruption.
It should be avoided otherwise your program would grab and more
memory diminishing the performance.

Nov 15 '05 #4
ra***********@gmail.com wrote:
Dear All

Is the Root Cause of the Memory corruption is the Memory leak, ??
suppose If in the code there is Memory leak, Do this may lead to the
Memory Corruption while executing the program ?

In nut shell, what is/are the realtion/s between the Memory Leak and
Memory Corruption.

Juts Theoritical Assumtion below:

Ideally Memory leak, may not lead to the Memory Corruption.
Here I am talking, if Memory leak Is accepted.


Memory leaks and memory corruption are completely different things. A
memory leak is loosing track of some memory you own, memory corruption
is overwriting memory you should not which might be owned by your
process or some other processs.

Imagine you are putting all of your stuff in to storage.

A memory leak is where you forget where one of the boxes is. The box
still exists, whatever it contains is still in it, but you can't get at
it because you don't know where it is (have no pointer to it).

Memory corruption is where you put so much in one box that it overflows
The overflow might land somewhere unused, in which case everything seems
OK at first sight, or it might spill over on to property owned by a
Mafia boss, in which case someone might come round and break your legs,
or it might spill over on to some priceless and extremely delicate
porcelain smashing it to pieces.
-
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 15 '05 #5

Flash Gordon wrote:
ra***********@gmail.com wrote:
Dear All

Is the Root Cause of the Memory corruption is the Memory leak, ??
suppose If in the code there is Memory leak, Do this may lead to the
Memory Corruption while executing the program ?

In nut shell, what is/are the realtion/s between the Memory Leak and
Memory Corruption.

Juts Theoritical Assumtion below:

Ideally Memory leak, may not lead to the Memory Corruption.
Here I am talking, if Memory leak Is accepted.
Memory leaks and memory corruption are completely different things. A
memory leak is loosing track of some memory you own, memory corruption
is overwriting memory you should not which might be owned by your
process or some other processs.

Imagine you are putting all of your stuff in to storage.

A memory leak is where you forget where one of the boxes is. The box
still exists, whatever it contains is still in it, but you can't get at
it because you don't know where it is (have no pointer to it).

Memory corruption is where you put so much in one box that it overflows
The overflow might land somewhere unused, in which case everything seems
OK at first sight, or it might spill over on to property owned by a
Mafia boss, in which case someone might come round and break your legs,
or it might spill over on to some priceless and extremely delicate
porcelain smashing it to pieces.
-


So guys dont you all think, assume if there is total memory leak,
And it leads to the finishing off the memroy, and then it may lead
to the Memory corruption.

Looks to me that if you dont have enough memory through the Memory
leaks
then it might be possible due to unavailbility of the memory, memory
corruption may occur.

Note:
Just I am trying to correlate the case between the Memory leak
and memory corruption. Above might be one situation.

Flash Gordon:

I am really very affraid of Mafia Boss, So I mostly Pick all my
belongings vaccate the place before I leave for outing. :-)
I do follow the Cleaning of memories as soon it is done.
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.


Nov 15 '05 #6
ra***********@gmail.com wrote:

<snip>
So guys dont you all think, assume if there is total memory leak,
And it leads to the finishing off the memroy, and then it may lead
to the Memory corruption.
Why would it?
Looks to me that if you dont have enough memory through the Memory
leaks
then it might be possible due to unavailbility of the memory, memory
corruption may occur.
No, or at least not directly. If you fail to check the return value of
malloc and friends then you might try to write through a null pointer
which could corrupt something, but on a lot of systems it will just lead
to an immediate crash.
Note:
Just I am trying to correlate the case between the Memory leak
and memory corruption. Above might be one situation.


The only correlation in general is that programmers who write software
with memory leaks are likely to also make other mistakes.

Memory corruption is generally caused by overrunning buffers, using
memory after it has been freed and double freeing. I've never come
across memory being corrupted because a process ran out of memory.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 15 '05 #7
>Is the Root Cause of the Memory corruption is the Memory leak, ??

No, because the program needs to do something wrong other than leak
memory to lead to memory corruption. One such thing is failure to
check for a NULL return from malloc() before trying to use the
memory. (Memory leaks MAY cause malloc() to return NULL when it
otherwise wouldn't have.) Another is to use more memory than what
was actually allocated (array subscript out of bounds), but that
has nothing to do with leaks.
suppose If in the code there is Memory leak, Do this may lead to the
Memory Corruption while executing the program ?
Only if the program does something else wrong/stupid. Arguably,
being born may lead to memory leaks because you might later learn
C, and write code after learning C, and it might contain a memory
leak. But I wouldn't claim that being born causes memory leaks.
In nut shell, what is/are the realtion/s between the Memory Leak and
Memory Corruption.
They are not married to each other. They usually aren't related at all.
About the only relation comes when a memory leak causes malloc() to
return NULL, and the program also fails to check whether malloc()
succeeded (THIS is the root cause, not the leak) and corrupts memory
because of that.
Juts Theoritical Assumtion below:

Ideally Memory leak, may not lead to the Memory Corruption.
Here I am talking, if Memory leak Is accepted.


Memory leaks are not accepted as currency anywhere I have ever
heard of. What do you mean by "accepted" in this context?

Gordon L. Burditt
Nov 15 '05 #8
Mac
On Thu, 18 Aug 2005 23:29:23 -0700, junky_fellow wrote:

ra***********@gmail.com wrote:
Dear All

Is the Root Cause of the Memory corruption is the Memory leak, ??
suppose If in the code there is Memory leak, Do this may lead to the
Memory Corruption while executing the program ?

In nut shell, what is/are the realtion/s between the Memory Leak and
Memory Corruption.

Juts Theoritical Assumtion below:

Ideally Memory leak, may not lead to the Memory Corruption.
Here I am talking, if Memory leak Is accepted.

Memory leak is a bug in your program where the memory is allocated
but not freed afterwards although it is never used again.
It has nothing to do with memory corruption.
It should be avoided otherwise your program would grab and more
memory diminishing the performance.


Well, I think a memory leak is best defined as repeatedly allocating
memory then losing track of where it is (so that it cannot be used or
freed).

If you allocate some memory once, don't lose track of it, and rely on
the OS to reclaim the memory when the process terminates, that is arguably
NOT a memory leak.

--Mac

Nov 15 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: blugus | last post by:
Hi Guys, I've been try to use Dinkum STL library. It workes well first, but report memory leak in MFC Debug Mode. I use Dinkum Unabridged Library for VC++ V4.02, MSVC6, WIN2000 SERVER. I...
5
by: RoSsIaCrIiLoIA | last post by:
why not to build a malloc_m() and a free_m() that *check* (if memory_debug=1) if 1) there are some errors in bounds of *all* allocated arrays from them (and trace-print the path of code that make...
10
by: eyh5 | last post by:
Hi, My C code (running on Soalris Unix) has some "segmentation fault" that I wish to use purify to do it. I poked around the web, and found some information about adding some lines in a Makefile...
4
by: Tomassus | last post by:
Hi there, I have a problem with dynamic memory allocation. I know that it would have been easier to use vectors methods, but i want to know what i do here wrong. This is one of my methods in...
3
by: talefsa | last post by:
Hi, I'm trying to figure out the origin of a memory corruption in my code using valgrind. valgrind gave me a number of messages that didn't help much, the first invalid read/write message is as...
9
by: Bruno Barberi Gnecco | last post by:
I'm using PHP to run a CLI application. It's a script run by cron that parses some HTML files (with DOM XML), and I ended up using PHP to integrate with the rest of the code that already runs the...
16
by: KG | last post by:
Hi, I do have a question. int main() { char *p = (char *)malloc(9); strcpy(p,"TajMahal"); p++;
6
by: nmehring | last post by:
I have an MFC app with 2000 users. I have one user that experiences a crash in our software anywhere from 1 to 5 times a week when opening a particular module. No other users have reported this...
6
by: ashjas | last post by:
Hello all.. I am experiencing memory leakes in on of my applications that i am developing. the % of memory used for the application is increasing as shown in the top command on linux. The...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.