1832154 Members
3504 Online
110038 Solutions
New Discussion

top command in HP-UX

 
harida
New Member

top command in HP-UX

Hi,
Does "top " shows the decrease in memory used
by a process. ?

I will escribe the problem we faced in detail.
-----------------------------------------
Problem observed :we created a program which
allocates and deallocates memory in larger chunks. (in HP-UX 10.0 ).
Monitored the excution of the program through
top.
Top showed the increase in memory usage by the program, when program was collecting memory.
But when program released the acquired memory , top continued to show the old memory usage only. That is top never reported
the decrease in memory usage by the program.

Later we checked the program with purify.5.0.1 tool for mem leaks but it showed no mem-leaks.

In short , my doubt is regarding the capability of "top " command to show the Decrease in used mem size in the RES field.

Thanks in advance,
harida
2 REPLIES 2
Santosh Nair_1
Honored Contributor

Re: top command in HP-UX

Harida,

When memory is allocated to a program, even though the program may later deallocate it, the memory is still assigned to the program. Future requests for memory will be assigned from this free space . So in other words, once memory is assigned to a program, that memory is considered unavailable until the program ceases to exist.

Hope this helps.

-Santosh
Life is what's happening while you're busy making other plans
A. Clay Stephenson
Acclaimed Contributor

Re: top command in HP-UX

Hi:

I assume you are using malloc(), calloc(), realloc(), and free(). In that case, memory areas supplied as arguments to free() are put back on the heap
for use by the same process. The memory is not returned to the OS. However, there is a method which will return memory to the OS, you can call sbrk() with a negative value to shrink a program's data segment. This method is not for the faint of heart. You will have to take over all responsibilty for memory management and use the brk() and sbrk() system calls.

Regards, Clay
If it ain't broke, I can fix that.