[fpc-pascal] New object created in custom pool

JoshyFun joshyfun at gmail.com
Tue Oct 28 11:18:33 CET 2008


Hello FPC-Pascal,

My application will create thousands of small objects of the same
class, this objects are not created or destroyed in a row, so memory
fragmentation could becomes a serious problem after some time.

My question is: Is there any way to override the object creation to
use a specific memory block ? This means, I plan to get a quite big
bunch of continuos memory block at the beginning to allocate the
needed space for all objects of that specific class and assign slots
"manually" and reduce the memory fragmentation.

In other words, is there any way to write something like overriding the
create method like:

constructor MyObject.Create()
begin
     result:=GetMem(sizeof(myobject));
end;

Thank you.

-- 
Best regards,
 JoshyFun




More information about the fpc-pascal mailing list