Process to consume memory for testing

This isn’t very pretty or precise, but it does eat up a ton of memory. Use svmon -P or svmon -S PID to see what is going on:

#include 
#include 

#ifndef BUFSIZE
#define BUFSIZE 20480
#endif

#ifndef NBUFS
#define NBUFS 81920
#endif

int main(void)
{
size_t nbytes = 2147483647;
char *p[9555559];
char *q[9555559];
char *r[9555559];
char *s[9555559];
int x;


if (nbytes == 0)
nbytes = 1;

(void) printf("Allocating %zu bytes\n", nbytes);
(void) fflush(stdout);

for (x = 0 ; x < 9555559 ; x = x + 1 )
{
p[x] = malloc(nbytes);
q[x] = malloc(nbytes);
r[x] = malloc(nbytes);
s[x] = malloc(nbytes);

}

(void) pause();
return (EXIT_SUCCESS);
}

Also, here is an svmon script for all processes:

ps aux | while read A B C
   do
  svmon -P $B | grep $B
   done