From: Koen Vincken (koen@cv.ruu.nl)
Date: 06/29/93


From: koen@cv.ruu.nl (Koen Vincken)
Subject: virtual memory tester
Date: Tue, 29 Jun 1993 10:49:40 GMT


The following program should check how much virtual memory there is.
For one reason or another the program fails (probably) on the 'if'
statement (it continues looping).

Anybody got a clue ?

        Koen

    / / Koen Vincken, Computer Vision Research Group,
   / / _ / ___/ \ / AZU E02.222, Heidelberglaan 100, 3584 CX Utrecht,
  / \ / / _/ / \ / The Netherlands. Phone: +31-30-506710/506711.
__/ _\ ____/ ____/ _/ _/ E-mail: koen@cv.ruu.nl (or vincken@cs.unc.edu).

==============================================================================

/* virtmemory.c - check how much virtual memory there is available */

#include <stdio.h>
#include <malloc.h>

main()
{
    long lVirtMemory = 1000000L;
    long lVirtStep = lVirtMemory;
    char *pcBuffer;
    
    
    while (lVirtStep > 1024L)
    {
        pcBuffer = malloc(lVirtMemory);
        if (pcBuffer)
        {
            /* allocation succesful */
            free(pcBuffer);
            lVirtMemory += lVirtStep;
        }
        else
        {
            lVirtStep /= 2;
            lVirtMemory -= lVirtStep;
        }
    }
    printf("Available continuous virtual memory: %ld KBytes\n",lVirtMemory/1024);
    
}

==============================================================================