1829107 Members
2581 Online
109986 Solutions
New Discussion

memory usage

 
Ken Hunter
Advisor

memory usage

Okay - I'm told that when a programmer makes a call to free() in hpux 10.20 - the memory is only available to the executable that originally malloc'd the memory to begin with - versus being returned to the system wide pool of available memory.

Example: We have an application that is 'supposedly' not leaking memory - however when reviewing with Glance, the Virtual and Resident memory will increase with certain usages of this program's functionality - but never decrease.

Are there any known 'isms' with regard to hpux 10.20 (December 1999 Gen. Release patches)?

thanks in advance,

Ken
Lead, Follow, or Get out of the Way! - USMC
1 REPLY 1
Sam Nicholls
Trusted Contributor

Re: memory usage

This is correct. Once allocated, process virtual memory is never really freed back to the system. However, the malloc/free calls maintain their own pool of free memory. When you call free(), you make the memory available to subsequent malloc() calls so that they don't have to keep extending the processes' data segment by calling sbrk(). Well behaved programs that malloc/free correctly, should not leak memory.

The K&R C book has an example implementation of malloc() and free() that show what is going on.

-sam