Hi
AFAICR 'AllocMem' initializes allocated memory to zeroes before returning it to you. ...And there's 'FreeMemAndNil', which deallocates mem sets the pointer to nil.
var
ManagedMem = array of byte; // dynamic array
begin
setlength(ManagedMem,100); // uninitialized
... use your lump of 100 bytes mem ...
// since dynamic arrays are managed types,
// this deallocates when going out of scope
end;
Otherwise, @Thaddy did something clever with 'SmartPointer', you'll have to search the forum for that...
Regards Benny