memory leak problem

hi all

Can any one plz explain me about memory leak problem

Thankx

This happens when you dynamically take memory from the heap (e.g. by calling malloc()) and forget to release it (free())

1 Like

try using rational purify to check the amount of memory leaked

What's the rational purify?

He is suggesting a tool for you to use to locate memory leaks in code. From your question, it sounds like you wanted to understand a memory leak, maybe not fix it.

Other tools: electric fence, valgrind

Hello sonali

If this is a new development and if you are going to use multi-thread processes (pthread), and if they will live very long time, and if you are going to develop in C++.

Then I recommend you to use smart pointers and exceptions ( for error handling ) .

You could read about smart pointers at Boost C++ Libraries and also you can create such by yourselves. Pure C++ without any C influence. I've used such technique and the result is very nice. Programming is close to JAVA style. All resources allocated at constructor, deallocation at destructor. Check also what's written about C++ exception at the C++ standard.

There is other ways too. For example you can spawn new processes for each new "task", allocate and do not free anything, When the task is completed terminate the process, and OS will free everything.

Nevertheless which approach you gonna use to deal with "Memory/Resource Leaks"
Use valgrind to check what's up.

Best Regards
O.