[fpc-pascal] Memory allocation problem
batyann811 at gmail.com
Fri Feb 26 10:29:05 CET 2010
I'm looking for a function or a procedure that tries to allocate
memory and return nil on failure.
GetMem seems to be a good candidate but it doesn't works as expected.
The FreePascal documentations
that it returns nil on failure but it raises an out of memory
exception (may be bug ???) when I try to allocates too much memory on
linux (I haven't try on windows).
Since my code is in fpc mode I can't catch the exeption. I know that
there is a ReturnNilIfGrowHeapFails variable but this changes the
behaviour of the all memory allocation system... I think I can do
something like the following code but I fear it's not thread safe.
function GetMemOrNil(size: PtrInt): pointer;
tmp : boolean;
Ps : Sorry for poor english. I hope you can understand me.
More information about the fpc-pascal