Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!princeton!phoenix.Princeton.EDU From: tasayco@phoenix.Princeton.EDU (Maria Tasayco) Newsgroups: comp.os.minix Subject: free memory Keywords: minix, free memory Message-ID: <3189@idunno.Princeton.EDU> Date: 8 Oct 90 00:37:24 GMT Sender: news@idunno.Princeton.EDU Organization: Princeton University, Princeton, New Jersey Lines: 35 I wrote a simple program to find out how much free memory is there in the heap (or the largest available chunk), at least I hoped that would be the result! Instead I found that it returns a much smaller value (my setup is an Atari 1040ST with 1MB and around 430kB of free memory when Minix boots up): it returns consistently 56kB. I looked into the source for sbrk() and it looked OK. Maybe this behaviour is to be expected but I don't see why. The program is short and follows: #include #define ulong unsigned long extern char *sbrk(); int main() { char *tp, *tp0, *tp1; long top = 0; /* Get memory top (at least that's what I think it should do) */ tp0 = sbrk((int)0); /* Try to get 1kB until no more available */ while ((tp = sbrk((int)1024)) != (char *)-1) tp1 = tp; /* Show the result */ printf("free memory = %ldkb\n", ((ulong)tp1 - (ulong)tp0)/1024); return(0); } Any comments are welcome (even if they tell me how dump I am). Francisco Figueirido e-mail: tasayco@phoenix.princeton.edu