Red de conocimientos turísticos - Información de alquiler - ¿Dónde está el código fuente para la detección de memoria?

¿Dónde está el código fuente para la detección de memoria?

¿Es

Unidad ShenNewMemMgr

Interfaz

var

GetMemCount: Integer = 0

FreeMemCount: Entero = 0;

ReallocMemCount: Entero = 0;

mmPopupMsgDlg: Booleano = Verdadero

mmShowObjectInfo: Booleano = Verdadero; mmSaveToLogFile: Boolean = True;

mmErrLogFile: string = '';

Procedimiento SnapToFile(Nombre de archivo:

Implementación

Uso

Windows,

SysUtils,

TypInfo

const

MaxCount = Alto(Palabra

var

OldMemMgr: TMemoryManager

ObjList: matriz[0 .

FreeInList: Entero = 0

procedimiento; AddToList(P: Puntero);

comenzar

si FreeInList > High( ObjList) entonces

comenzar

MessageBox(0, ' Lista de punteros del monitor de administración de memoria desbordada, aumente el número de elementos de la lista,

'Monitor de administración de memoria', mb_ok + mb_iconError

Salir

fin;

ObjList[FreeInList] := P;

Inc(FreeInList

fin

Procedimiento RemoveFromList[FreeInList] := P;

Inc(FreeInList);

fin

fin p> Procedimiento RemoveFromList(P: Puntero); var

I:Entero;

comenzar

//para I := 0 a FreeInList - 1 hacer

para I :

si ObjList[I] = P entonces

comenzar

Dec(FreeInList

Move(ObjList[I + 1]), ObjList[I], (FreeInList - I) * SizeOf(Pointer));

Salir

fin

fin; > Procedimiento SnapToFile(Nombre de archivo: cadena);

var

OutFile: TextFile.

I,

CurrFree,

>

Tamaño de bloque: Entero;

Estado del montón:

Elemento: TObject;

ptd: PTypeData

ppi: Inicio<; /p>

AssignFile(OutFile, Filename);

intente

si FileExists(Filename) entonces

Append(OutFile) write(OutFile, ' Bytes) - En ');

escribir(OutFile, ptd.UnitName);

escribir(OutFile, '.pas'); /p>

excepto

en Excepción

write(OutFile, 'no es un objeto');

end; > escribir(OutFile);

final;

final;

final; //finalizar si CurrFree

final; >

fin;

fin

fin

CerrarFile(OutFile); p> fin;

fin;

función NewGetMem(Tamaño. Entero: Entero): Puntero

comienzo

Inc( GetMemCount;

Resultado := OldMemMgr.GetMem(Tamaño);

AddToList(Resultado

fin

función NewFreeMem( P: Puntero).Entero;

comenzar

Inc(FreeMemCount

Resultado := OldMemMgr.FreeMem(P); > RemoveFromList(P);

fin

función NewReallocMem(P: Puntero; Tamaño: Entero):

comienzo

Inc (ReallocMemCount);

Resultado:= OldMemMgr.P, Tamaño

RemoveFromList(P);

AddToList(Resultado); p> fin;

const

NewMemMgr: TMemoryManager = (

GetMem. NewGetMem;

FreeMem: NewFreeMem;

ReallocMem: NewReallocMem);

Inicialización

GetMemoryManager(OldMemMgr);

SetMemoryManager(OldMemMgr

Constante

NewMemoryMgr.p> SetMemoryManager(NewMemMgr

finalizat);

ion

SetMemoryManager(OldMemMgr);

si (GetMemCount - FreeMemCount) <> 0 entonces

comenzar

si mmPopupMsgDlg entonces p>

MessageBox(0, PChar(Format('Agujero de memoria en %d.)):',

[GetMemCount - FreeMemCount])), 'Monitor de administración de memoria', MB_OK)

p>

De lo contrario

OutputDebugString(PChar(Format('Error de memoria en %d:', [GetMemCount -

FreeMemCount])))

end;

OutputDebugString(PChar(Format('Get = %d Gratis = %d Realloc = %d',

[GetMemCount,

p>

FreeMemCount, ReallocMemCount])));

si mmErrLogFile = '' entonces

mmErrLogFile := ExtractFileDir(ParamStr(0)) + '\Memory.Log' ;

si mmSaveToLogFile entonces

SnapToFile( mmErrLogFile

fin.