fixed AllocateOSMemory