cancel
Showing results for 
Search instead for 
Did you mean: 

memory leakage

SOLVED
Go to solution
Sachin Soni_1
Frequent Advisor

memory leakage

Hi All.

Not a problem , just a doubt.
What is memory leakage?
how it affects the system performance.
and what are the tools for that.

Thanks
sachin
N-joy
6 REPLIES
Santosh Nair_1
Honored Contributor

Re: memory leakage

A memory leak is when an application grabs memory but doesn't properly release it. Eventually the application if not checked, the application could grab all the memory available on the system thus not allowing anything else to run.

Typical tools to check for this would be top, glance, and ps, e.g.

UNIX95= ps -e -o vsz=Kbytes

Hope this helps.

-Santosh
Life is what's happening while you're busy making other plans
John Poff
Honored Contributor

Re: memory leakage

Hello,

Memory leakage happens when a program has a bug that causes it to use more and more memory without releasing it properly. For example, we are running an Oracle web server here that has a memory leak. As it runs I can use the 'ps' command to see how much memory it uses, and it will continue to increase as long as the program runs, even when all the users disconnect at the end of the day. The answer is to get the bug fixed, or to just stop and restart the offending program at regular intervals. Our web server gets started and stopped each day, so it isn't a big problem for us.

I'm only a novice C programmer, but I believe that misuse of the 'malloc' function for allocating memory can cause memory leakage in C programs. Probably one of the other local experts can explain it better.

A memory leak in one of the system daemons can be a problem, but HP-UX is very mature and those kind of problems are extremely rare.

JP
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: memory leakage

Hi:

It's just what it sounds like. The most common
error is that the programmer makes a call to a memory allocation function malloc(),calloc(),realloc(), or the system call sbrk() without
making a matching call to the function free(). One thing to note is that the malloc(), calloc(), etc (as opposed to the sbrk() system call) do not actually return memory to the OS but just make the memory available to the process for reuse. Processes with memory leaks grow with time and can eventually hog all the resources. This is the main reason for not setting maxdsiz to a very large value especially on development machines. The memeory allocations fail when process maxdsiz is reached rather that when almost all the system resources are exhausted.

One fairly easy way to watch for memory leaks is to use the ps -el command and look at the SZ column. You can also unix the UNIX95 versions of ps to do the same thing.

Clay
If it ain't broke, I can fix that.
Deshpande Prashant
Honored Contributor

Re: memory leakage

Hi
Another way to monitor memory leak will be to use
#ipcs -mob command.
Large number of same hex KEY numbers with NATTCH value to 0, can be suspected for memory leaks.
The hex numbers are normally applicaion specified.

Thanks.
Prashant.
Take it as it comes.
Sanjay_6
Honored Contributor

Re: memory leakage

Bill Thorsteinson
Honored Contributor

Re: memory leakage

As stated above a memory leak results when a process
allocates memory from the operating system, but does
not return it when done. It is not much of a problem
for programs that run for a short time, as all memory
is returned when the program terminates.

I worked with a SUN system that died due to a memory
leak. There was a requirement to watch the size of
the Oracle processes on the system. A monitoring
process was slowly leaking memory. Post-mortem
analysis showed available swap space slow decreased
over a period of two weeks. During the last day free
memory decreased until there was no memory to
launch a new process.