top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

What is memory leak?

+2 votes
59 views

From so many days I was thinking what should be treated as memory leak and what should not be. Checked few links and wiki also but could not get satisfactory answer so that to ask here?

What you guys say about it i.e. what is considered as a memory leak in a program?

posted Oct 22, 2014 by Salil Agrawal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

As per theoretical definition, if a process allocates a memory chunk and does not release after using it. This event is known as "Memory Leak".
Now come to practical definition of it. Every software has some requirement parameters like processor, memory, primary storage and secondary storage etc. While running if software takes memory more then what it suppose to take then it is known as memory leak and that situation may lead segmentation fault/system crash.

It is better to use tools like valgrind, purify etc to detect possible memory leaks and fix it before making any software release.

answer Oct 23, 2014 by Harshita
0 votes

Just a high level info in simple words.
Whenever our application needs memory, it requests the Operating System because OS is the resource manager who takes care of sharing the valuable resources like CPU time & RAM among all the processes in a fair manner.

So when an application requests the OS for memory, the OS TAGS that memory location signifying that no other process is supposed to use this memory. And when we free this memory, the OS UNTAGS it so that it can be used by other processes. Now guess what happens if we forget to free this memory after our job is done??

This memory is left useless & wasted. Now since this memory is TAGGED, the OS cannot allocate this to any other process. This is called memory leak where the memory is only reserved but not used.

So to avoid this, the best practice is to run your code with valgrind / purify as suggested by Harshita.

Hope this helps!!

answer Oct 28, 2014 by Ankush Surelia
Similar Questions
+2 votes

Code is in C/C++ and some scripts in shell and PHP, any suggestion other then building inhouse tool.

+5 votes

My doubt is that doesn't Java virtual machine have a garbage collector that will collect and free all unreferenced memory automatically?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...