Returning "freed" memory to system

yuri mironoff (yuri@buster.rgti.com)
Wed, 14 May 1997 12:02:14 -0400 (EDT)


Hello!

I remember a discussion about returning "freed" memory to the system
while the process is still executing. Apparently AIX has a mechanism for
forcing this to happen. Is this an AIX or POSIX thing, and if so would
this be a good thing to implement?

Regards,

Y.

(Excerpt from IBM rep follows: )

...if a large structure is used early and then left untouched for the
remainder of the program, it should be released. It is not sufficient to
free the space that was malloced or calloced. free releases only the
address range that the structure occupied. In order to release the real
memory and paging space, you must disclaim the space as well.

disclaim Subroutine

Purpose
Disclaims the content of a memory address range.

Syntax

#include <sys/shm.h>

int disclaim (Address, Length, Flag)
char *address;
unsigned int Length, Flag;

Description

The disclaim subroutine marks an area of memory having content that is no
longer needed. The system then stops paging the memory area. This
subroutine connot be used on memory that is mapped to a file by the shmat
subroutine.

Parameters

Address Points to the beginning of the memory area.

Length Specifies the length of the memory area in bytes.

Flag Must be the value ZERO_MEM, which indicates that each memory
location in the address range should be set to 0.

Return Values

When successful, the disclaim subroutine returnes a value of 0.

Error Codes

If the disclaim subroutine is unsuccessful, it returns a value of -1 and
sets the errno global variable to indicate the error. The disclaim
subroutine is unsuccessful if one or more of the following are true:

EFAULT The calling process does not have write access to the area of
memory that begins at the Address parameter and extends for the number of
bytes specified by the Length parameter.

EINVAL The value of the Flag parameter is no valid.

EINVAL The memory area is mapped to a file.