[fpc-pascal]Exception w/ Freemem()

Jonas Maebe jonas at zeus.ugent.be
Fri Apr 11 09:55:21 CEST 2003


On vrijdag, apr 11, 2003, at 07:32 Europe/Brussels, Jon Sawyer wrote:

>   If MaxAvail > (iWidth*iHeight*SizeOf(tQPixel)) then
>   Begin

Note that you should leave this line out. MaxAvail only indicates how 
much of the memory that's currently allocated to your application is 
still free. Once that memory is full and you allocate more, the RTL 
will ask the OS to grow the heap of your program. Once memory is 
exhausted (though this can happen long after you've used all physical 
memory in the computer, since the OS will use swapping to give you 
more), you will get a run time error 204. To catch this and make sure 
your program doesn't stop then, you have to use exceptions (uses 
sysutyils; and a try..except block, see the manual for more info).


Jonas




More information about the fpc-pascal mailing list