home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d5xx
/
d571
/
gwin.lha
/
Gwin
/
Examples
/
recovermem.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-12-22
|
2KB
|
46 lines
#include "gwin.user.h"
main()
{
UBYTE *AllocMem(), *fake1, *fake2;
/* What, you may ask, is this? Well I usually test memory */
/* allocation/deallocation by checking to see if the */
/* available memory is the same after I run my program */
/* as it was before I run my program. On the Amiga, it */
/* is not. Some sort of screwball accounting is being */
/* done by the operating system so that if you used */
/* diskfonts (which I do), the memory does not REALLY */
/* free itself up until you try to allocate more than is */
/* "virtually free". By attempting to allocate a large */
/* block of memory, (in this case, 10 megabytes which is */
/* impossible) we fake the system out into freeing */
/* everything so that we can tell if we forgot to free */
/* our own personal memory. If you check the memory that */
/* appears to be available before running a program, that */
/* opens a diskfont, then run the program, then look at */
/* the memory availability again, it will look like you */
/* forgot to release memory. If you run recovermem, the */
/* ACTUAL memory available will be reset to what it */
/* REALLY is! */
/* This program will also remove libraries if their open */
/* counts are 0. All sorts of amazing things... */
/* I have put code similar to this in the uend routine */
/* of GWIN. It occurs right before the call to the user */
/* cleanup handler. */
fake1 = AllocMem(10000000,MEMF_CHIP);
fake2 = AllocMem(10000000,MEMF_FAST);
if(fake1) FreeMem(fake1,10000000);
if(fake2) FreeMem(fake2,10000000);
}