Teknologi Komputer dan Internet > Delphi/Pascal

[Delphi] Memory Manager di Windows

(1/1)

descrates:
di delphi banyak memory manager, dari yang native FastMM sampai scaleMM
dan semua kurang greget jatuhnya (kalau melihat perkembangan)
nah gw juga gitu, awalnya pakai FastMM tapi makin jatuh performance
terus gw doping pakai msvcrtMM, lumayan ngangkat karena inget MinGW
tapi karena butuh yang strong, maka pilihan gw: msvcrtMM + QiuMM
jadilah tandem yang lumayan

yang msvcrtMM.pas (msvcrt100 keatas)

---------------------------------------------
unit msvcrtMM;

interface

implementation

type
  size_t = Cardinal;

const
  msvcrtDLL = 'msvcr100.dll';

function malloc(Size: size_t): Pointer; cdecl; external msvcrtDLL;
function realloc(P: Pointer; Size: size_t): Pointer; cdecl; external msvcrtDLL;
procedure free(P: Pointer); cdecl; external msvcrtDLL;

function GetMem(Size: Integer): Pointer;
begin
  Result := malloc(size);
end;

function FreeMem(P: Pointer): Integer;
begin
  free(P);
  Result := 0;
end;

function ReallocMem(P: Pointer; Size: Integer): Pointer;
begin
  Result := realloc(P, Size);
end;

function AllocMem(Size: Cardinal): Pointer;
begin
  Result := GetMem(Size);
  if Assigned(Result) then begin
    FillChar(Result^, Size, 0);
  end;
end;

function RegisterUnregisterExpectedMemoryLeak(P: Pointer): Boolean;
begin
  Result := False;
end;

const
  MemoryManager: TMemoryManagerEx = (
    GetMem: GetMem;
    FreeMem: FreeMem;
    ReallocMem: ReallocMem;
    AllocMem: AllocMem;
    RegisterExpectedMemoryLeak: RegisterUnregisterExpectedMemoryLeak;
    UnregisterExpectedMemoryLeak: RegisterUnregisterExpectedMemoryLeak
  );

initialization
  SetMemoryManager(MemoryManager);

end.
---------------------------------------------

QiuMM

https://code.google.com/archive/p/qiumm/source/default/source


Navigasi

[0] Indeks Pesan

Ke versi lengkap