Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site Navajo.ARPA Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!glacier!Navajo!rokicki From: rokicki@Navajo.ARPA Newsgroups: net.micro.amiga Subject: Amiga memory management Message-ID: <301@Navajo.ARPA> Date: Fri, 24-Jan-86 23:36:51 EST Article-I.D.: Navajo.301 Posted: Fri Jan 24 23:36:51 1986 Date-Received: Sun, 26-Jan-86 05:13:26 EST Distribution: net Organization: Stanford University Lines: 42 *** REPLACE THIS LINE WITH YOUR BROTHER *** Here is a simple C routine I threw together which should determine the amount of memory accessible by C (at least a rough approximation.) When I run it, it dies; but it consists solely of calls to AllocMem! Any hints out there? /* * This routine finds out how much memory is available to a C program * by simply allocating successively larger pieces until it fails, * and then successively smaller pieces, adding them up as it goes. * This will only work if the memory is not terribly fragmented, but * if it is, it might not be that useful, eh? */ char *AllocMem() ; main () { char *p ; int i, j ; j = 0 ; for (i=4; 1; i<<=1) { p = (char *)AllocMem(i, 0) ; if (p == 0) break ; else { j += i ; printf("%d %d\n", i, j) ; } } for (; i>=4; i>>=1) { p = (char *)AllocMem(i, 0) ; if (p !=0) { j += i ; printf("%d %d\n", i, j) ; } } } It crashes the machine (at least it crashes my 512K machine). Help! I want my program to take advantage of the memory available, but if it can't even figure how much exists, how can it? -tom