Finding/changing max memory size available

Richard Steinberger ric at ace.sri.com
Wed May 29 01:41:43 AEST 1991


The following short program finds the maximum amount of memory that can be
allocated through use of malloc().  What I'd like to know is, "Where/How
is this limit set?  Is this a a function of 1 or more kernel parameters,
or other system configuration variables?"  Can the upper allocatable memory
limit be changed (without adding physical memory, of course)?  Thanks for
any replies.

regards,

	ric steinberger
	ric at ace.sri.com

/****************************************************************************/

#include <stdio.h>
#include <stdlib.h>

#define MALLOC_SIZE 1000000L        /* Number of bytes to allocate / call */

main()
{
  char *cptr;
  long i;

  while ((cptr = malloc(MALLOC_SIZE)) != NULL)
    i++;

  printf("Total memory allocated = %u bytes.\n", i*MALLOC_SIZE);
  exit(0);
}

/****************************************************************************/



More information about the Comp.lang.c mailing list