Working with TManagedMemory is a simple, three-step process: allocate, manipulate, and release. So first step is to call Allocate to reserve the memory block for us, like this:


var MyBuffer := TManagedMemory.Create;

MyBuffer.Allocate(1024); // Allocate 1KB of memory


This has the exact same result as calling allocmem() in Delphi or Lazarus, except here there are no pointers. You operate with an index into the memory buffer that is allocated.