473,320 Members | 2,083 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 leakage

i want to know that on what situation memory leakage happan and what
is the solution to solve the problem of memory leakage.

Feb 21 '07 #1
14 2304
On Feb 20, 7:30 pm, "madhawi" <madhaw...@gmail.comwrote:
i want to know that on what situation memory leakage happan
When you have more calls to malloc() and calloc() than you do to
free().
and what
is the solution to solve the problem of memory leakage.
Have one call to free() for each call to calloc() or malloc() that
your program makes.

If you want to fix something that's broken, look here:
https://buildsecurityin.us-cert.gov/...oding/311.html
Feb 21 '07 #2
i m working on a large project. and i used free() for memory. but
still i get problem. when i removed the line from where i m getting
memory leakage, then i get another problem, loss of information.
user923005 wrote:
On Feb 20, 7:30 pm, "madhawi" <madhaw...@gmail.comwrote:
i want to know that on what situation memory leakage happan

When you have more calls to malloc() and calloc() than you do to
free().
and what
is the solution to solve the problem of memory leakage.

Have one call to free() for each call to calloc() or malloc() that
your program makes.

If you want to fix something that's broken, look here:
https://buildsecurityin.us-cert.gov/...oding/311.html
Feb 21 '07 #3
On Feb 21, 8:30 am, "madhawi" <madhaw...@gmail.comwrote:
i want to know that on what situation memory leakage happan and what
<forwarded to comp.programming>

you allocate some memory,
you use those memory,
now you dont want the memory --you have done(and you should free the
memory)

you forgot to free the memory and go ahead, and now you cant come back
to free the memory.

i think this is called leak (I may need to more correct but this is
what basics come to my mind,)

http://en.wikipedia.org/wiki/Memory_leak
http://www.valgrind.org/docs/manual/...-start.prepare

is the solution to solve the problem of memory leakage.
yes, it is solvable,
1. Good Programming habits,
2. Good Toolset (for linux valgrind/memprof is reasonably good,)

--Raxit

Feb 21 '07 #4
i am using c++. i used delete and destructor to free the memory. can u
help me this in c++, please.
raxitsheth2...@yahoo.co.in wrote:
On Feb 21, 8:30 am, "madhawi" <madhaw...@gmail.comwrote:
i want to know that on what situation memory leakage happan and what

<forwarded to comp.programming>

you allocate some memory,
you use those memory,
now you dont want the memory --you have done(and you should free the
memory)

you forgot to free the memory and go ahead, and now you cant come back
to free the memory.

i think this is called leak (I may need to more correct but this is
what basics come to my mind,)

http://en.wikipedia.org/wiki/Memory_leak
http://www.valgrind.org/docs/manual/...-start.prepare

is the solution to solve the problem of memory leakage.

yes, it is solvable,
1. Good Programming habits,
2. Good Toolset (for linux valgrind/memprof is reasonably good,)

--Raxit
Feb 21 '07 #5
madhawi wrote:

Please don't top-post.
user923005 wrote:
>>On Feb 20, 7:30 pm, "madhawi" <madhaw...@gmail.comwrote:
>>>i want to know that on what situation memory leakage happan

When you have more calls to malloc() and calloc() than you do to
free().
>>>and what
is the solution to solve the problem of memory leakage.

Have one call to free() for each call to calloc() or malloc() that
your program makes.

If you want to fix something that's broken, look here:
https://buildsecurityin.us-cert.gov/...oding/311.html

i m working on a large project. and i used free() for memory. but
still i get problem. when i removed the line from where i m getting
memory leakage, then i get another problem, loss of information.
Please capitalise your sentences and 'I'.

Assuming your debugger supports is it, run the program with leak
checking enabled. If it doesn't, ask on a platform specific group about
tools to do this for you.

If you build your application in small, tested, steps checking for leaks
as you go, you stand a better chance of avoiding these problems.

--
Ian Collins.
Feb 21 '07 #6
madhawi wrote:
i am using c++. i used delete and destructor to free the memory. can u
help me this in c++, please.
u doesn't post here any more.

Sounds like you should either be asking on a C++ or Linux programming group.

--
Ian Collins.
Feb 21 '07 #7
"madhawi" <ma*******@gmail.comwrites:
i want to know that on what situation memory leakage happan
Memory is allocated but not deallocated.
and what
is the solution to solve the problem of memory leakage.
Deallocate any memory that you allocate.

Memory is allocated by calling malloc() and deallocated by calling
free(). Each chunk of memory allocated by malloc() should be released
by calling free() when you're done with it.

Of course it's not necessarily that simple, but explaining the details
would be equivalent to explaining how to program.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 21 '07 #8
I am asking in C++. I use my application on Window2000.
Ian Collins wrote:
madhawi wrote:
i am using c++. i used delete and destructor to free the memory. can u
help me this in c++, please.

u doesn't post here any more.

Sounds like you should either be asking on a C++ or Linux programming group.

--
Ian Collins.
Feb 21 '07 #9
madhawi wrote:
I am asking in C++. I use my application on Window2000.
When you do, don't forget not to top post!
Ian Collins wrote:
>>madhawi wrote:
>>>i am using c++. i used delete and destructor to free the memory. can u
help me this in c++, please.

u doesn't post here any more.

Sounds like you should either be asking on a C++ or Linux programming group.

--
Ian Collins.
Feb 21 '07 #10
"madhawi" <ma*******@gmail.comwrites:
I am asking in C++. I use my application on Window2000.
[...]

Pay very close attention to the following.

Please do not top-post. Read the following web pages to understand
what "top-posting" is, and why you shouldn't do it.

http://www.caliburn.nl/topposting.html
http://www.cpax.org.uk/prg/writings/topposting.php

You are asking about C++. This is comp.lang.c. C and C++ are two
different languages. If you have questions about C++, comp.lang.c++
is the place to ask. This is not.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 21 '07 #11
madhawi wrote:
Ian Collins wrote:
madhawi wrote:
i am using c++. i used delete and destructor to free the memory. can u
help me this in c++, please.
u doesn't post here any more.

Sounds like you should either be asking on a C++ or Linux programming group.

I am asking in C++. I use my application on Window2000.
this link helped me
http://www.kbcafe.com/articles/Memory.Leaks.pdf

it is actually buggy, but provided enough clues for me to find leaks
in a
large win32 app
--
Nick Keighley

Feb 21 '07 #12

madhawi wrote:
I am asking in C++. I use my application on Window2000.
[top-post snipped]

If it's a generic C++ question post to comp.lang.c++. If your problem
involves platform specific extensions, it might be better to post to a
more platform specific group like comp.os.ms-windows.programmer.win32.

Feb 21 '07 #13
madhawi schreef:
i m working on a large project. and i used free() for memory. but
still i get problem. when i removed the line from where i m getting
memory leakage, then i get another problem, loss of information.
You may be freeing the wrong pointer. In other words: you may be freeing
useful data? There is absolutely no guarantee that a free'd block of
memory still contains any useful data.

--

Cheers,

John den Haan
joDhn[dot]haEan[at]chLello[dot]nl

Remove capital 'DEL' from above addy to obtain e-mail address
Feb 23 '07 #14
At about the time of 2/20/2007 8:31 PM, madhawi stated the following:

Please don't top-post.
I am asking in C++. I use my application on Window2000.
Ian Collins wrote:
>madhawi wrote:
>>i am using c++. i used delete and destructor to free the memory. can u
help me this in c++, please.
u doesn't post here any more.

Sounds like you should either be asking on a C++ or Linux programming group.

--
Ian Collins.
This group is C only, not C++, not Apple C, not coca, not PL1, fortran,
pascal, or anything else. C only. Since your question is a C++
question, post your question in comp.lang.c++ instead of here.

As for Windows 2K, you'll need to post in one of the
comp.os.ms-windows.programmer groups, or another group that supports
your platform. You may also try one of Microsoft's programming forums
on their developer's network (requires subscription though).

As for a memory leak, the best way to avoid it is for every call to
malloc that you make, there should also be a corresponding free
statement. If you destroy the contents of a pointer before calling
free, then that memory remains allocated but unaccessible since you no
longer know where it is. So as your program keeps executing the same
piece of code, the memory usage will get larger and larger until you
eventually run out. What happens then is implementation specific.

I do know that on some implementations if you call free twice, you will
get a warning (mainly on the unix style platforms). But, IIRC, call
free on a block of memory that is already free results in undefined
behavior.
--
Daniel Rudy

Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m

Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep
Feb 23 '07 #15

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

Similar topics

2
by: frustrated | last post by:
Before I begin, I must first make the following disclaimer: Although I have considerable programming experience, I do not consider myself by any means to be an expert C++ programmer. The following...
0
by: boy | last post by:
Hi all, I have created a simple template class as follow, but i encountered memory leakage on the base.Render(writer). Have all you of encountered the same problem? using System; using...
7
by: andylcx | last post by:
hi all: I have a code like below, is there any serious memory leakage in my code. I am confusion now but no idea how to fix it. In the member function of class A, I create a new object of class B...
18
by: Ramasubbu Ramasubramanian XR (AS/EAB) | last post by:
What is memory leakage, could any one explain with sample code
1
by: Gaël | last post by:
Hi everybody! I have a really big problem with ASP.NET application. I noticed that the w3wp.exe memory size, increase with the time and the use of my website. When it raise a certain value, w3wp...
2
by: chets | last post by:
Hi all Can anyone tell me what is the difference between:- *p=q; and p=&q; in C where declaration is like this char **p; char *q; Because if I do *p=q; in one file after mallocing q and...
0
by: kiran kumar | last post by:
Hi All, I am working on embedded python on C these days. I feel there is a memory leakage in this code. I have used our own memory pool and all the python code will use the heap from this memory...
7
by: madhawi | last post by:
please give me the solution for the problem of memory leakage.
11
by: prpradip | last post by:
I have an ImageList (_imageList). In _imageList I have put large numbers of Icons. Now what I need is to get Handle of all Icons that I put in _imageList, so that I can destroy (DestoryIcon) them...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.