Operating System - HP-UX
1832224 Members
2452 Online
110041 Solutions
New Discussion

memory does't decrease from peak

 
charles zhong
New Member

memory does't decrease from peak

We have a c++ application which does some select statement from database, even after we released the memory but the top command never shows memory decrease. If the result of select statement is big, the memory used by the application will increase, if the result of select statement is smaller than the previous one, the memory doesn't drop.
Is this normal behavior? Where can I find more information about this.
2 REPLIES 2
A. Clay Stephenson
Acclaimed Contributor

Re: memory does't decrease from peak

This is normal behavior. When you free() memory, it is returned to the process's heap for reuse in subsequent memory allocation calls; it is not returned to the system for general use.

If you want to return memory to the system, you must use the sbrk() system call with a negative increment; however, if you choose this method you MUST only use sbrk() and assume total responsibility for memory allocation. Absolutely no other method of memory allocation may be used either directly or through a library function.

If it ain't broke, I can fix that.
Deepak Extross
Honored Contributor

Re: memory does't decrease from peak

Yes, this is normal behaviour indeed.

See this link - and you'll find dozens more like it if you run a search on this forum.
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xc2d4a1abbac8d5118ff10090279cd0f9,00.html