Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* malloc/free in OpenVMS
@ 1995-10-19  4:00 dricci
  1995-10-20  4:00 ` Chris Scheers
  0 siblings, 1 reply; 2+ messages in thread
From: dricci @ 1995-10-19  4:00 UTC (permalink / raw)


I'm having a problem using malloc and free with a C program in OpenVMS. My PGFLQUOTA continues to climb even though I am 
freeing everything I have malloc'd. Has anybody come across this???

Thanks in advance for any help.

dricci @interserv.com




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: malloc/free in OpenVMS
  1995-10-19  4:00 malloc/free in OpenVMS dricci
@ 1995-10-20  4:00 ` Chris Scheers
  0 siblings, 0 replies; 2+ messages in thread
From: Chris Scheers @ 1995-10-20  4:00 UTC (permalink / raw)
  To: dricci

dricci@interserv.com wrote:
>I'm having a problem using malloc and free with a C program in OpenVMS. My PGFLQUOTA continues to climb even though I am 
>freeing everything I have malloc'd. Has anybody come across this???
>
>Thanks in advance for any help.

When running a program under VMS, your page file usage will never go 
down.  Page file space is only released when the image exits.

If a program is well behaved, the page file usage will go up to a 
certain point and then become stable.  Even if you free() everything 
that you have malloc()'d, your page file quota usage will stay the same. 
However, if you then malloc() again, your page file quota usage will not 
climb either.

If you are really free()ing everything you have malloc()'d, and your 
page file quota usage is still increasing, you may be suffering from 
memory pool fragmentation.  This can occur if you have a mix of both 
small and large memory blocks.

For example, you malloc() a large block and the free() it.  Then you 
malloc() a small block, which gets allocated out of the freed space from 
the large block.  Then you malloc() another large block.  Since the free 
large block is no longer large enough to satisfy the request, a new 
block gets allocated.  This can extend your page file quota usage.  If 
this happens enough, your memory pool is filled with holes which are not 
allocated, but are not large enough to be useful.

There are various ways to deal with this.  One way is to manage your own 
free lists of blocks instead of free()ing them back to the C RTL.  When 
you need another block, pull it from the free list.  This keeps the 
blocks from getting chunks nibbled out of them.

You may also want to put periodic calls to lib$show_vm() into your 
program to verify that you are really freeing everything.  This is 
pretty good at indicating if you have any memory leaks.

NOTE: Because of the way malloc() and free() work in the C RTL, 
lib$show_vm() count of freed blocks may be off by one.

-----------------------------------------------------------------------
Chris Scheers, Applied Synergy, Inc.

817-237-3360 (Voice)    817-237-3074 (Fax)    Internet: asi@airmail.net





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1995-10-20  4:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-10-19  4:00 malloc/free in OpenVMS dricci
1995-10-20  4:00 ` Chris Scheers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox