diff --git a/compiler/aasmdata.pas b/compiler/aasmdata.pas index bec28c5905..7e586dc356 100644 --- a/compiler/aasmdata.pas +++ b/compiler/aasmdata.pas @@ -155,6 +155,13 @@ implementation verbose, aasmtai; +{$ifdef MEMDEBUG} + var + memasmsymbols, + memasmcfi, + memasmlists : TMemDebug; +{$endif MEMDEBUG} + {***************************************************************************** TAsmCFI @@ -284,33 +291,33 @@ implementation destructor TAsmData.destroy; var -{$ifdef MEMDEBUG} - d : tmemdebug; -{$endif} hal : TAsmListType; begin + { Symbols } {$ifdef MEMDEBUG} - d:=tmemdebug.create(name+' - AsmSymbols'); + memasmsymbols.start; {$endif} FAltSymbolList.free; FAsmSymbolDict.free; {$ifdef MEMDEBUG} - d.free; + memasmsymbols.stop; {$endif} + { CFI } {$ifdef MEMDEBUG} - d:=tmemdebug.create(name+' - AsmCFI'); + memasmcfi.start; {$endif} FAsmCFI.free; {$ifdef MEMDEBUG} - d.free; + memasmcfi.stop; {$endif} + { Lists } {$ifdef MEMDEBUG} - d:=tmemdebug.create(name+' - AsmLists'); + memasmlists.start; {$endif} for hal:=low(TAsmListType) to high(TAsmListType) do AsmLists[hal].free; {$ifdef MEMDEBUG} - d.free; + memasmlists.stop; {$endif} end; @@ -403,6 +410,22 @@ implementation inc(FNextLabelNr[alt_addr]); end; -begin +initialization +{$ifdef MEMDEBUG} + memasmsymbols:=TMemDebug.create('AsmSymbols'); + memasmsymbols.stop; + memasmcfi:=TMemDebug.create('AsmCFI'); + memasmcfi.stop; + memasmlists:=TMemDebug.create('AsmLists'); + memasmlists.stop; +{$endif MEMDEBUG} CAsmCFI:=TAsmCFI; + +finalization +{$ifdef MEMDEBUG} + memasmsymbols.free; + memasmcfi.free; + memasmlists.free; +{$endif MEMDEBUG} + end. diff --git a/compiler/assemble.pas b/compiler/assemble.pas index 1a51e1cb07..ec289b0b2d 100644 --- a/compiler/assemble.pas +++ b/compiler/assemble.pas @@ -628,21 +628,11 @@ Implementation destructor TInternalAssembler.destroy; -{$ifdef MEMDEBUG} - var - d : tmemdebug; -{$endif} begin -{$ifdef MEMDEBUG} - d := tmemdebug.create(name+' - agbin'); -{$endif} if assigned(ObjData) then ObjData.free; if assigned(ObjOutput) then ObjOutput.free; -{$ifdef MEMDEBUG} - d.free; -{$endif} end; @@ -1361,9 +1351,6 @@ Implementation var to_do:set of TasmlistType; i:TasmlistType; -{$ifdef MEMDEBUG} - d : tmemdebug; -{$endif} procedure addlist(p:TAsmList); begin @@ -1385,23 +1372,6 @@ Implementation writetreesmart else writetree; - -(* - if assigned(objectlibrary) then - begin - if objectlibrary<>current_module.librarydata then - internalerror(200603013); -{$ifdef MEMDEBUG} - d:=tmemdebug.create(modulename^+' - librarydata'); -{$endif} - current_asmdata.free; - objectlibrary:=nil; - current_module.librarydata:=nil; -{$ifdef MEMDEBUG} - d.free; -{$endif} - end; -*) end; diff --git a/compiler/compiler.pas b/compiler/compiler.pas index 63988f6e67..0a8a86f5ca 100644 --- a/compiler/compiler.pas +++ b/compiler/compiler.pas @@ -114,10 +114,7 @@ implementation uses aasmcpu; -{$ifdef EXTDEBUG} - {$define SHOWUSEDMEM} -{$endif} -{$ifdef MEMDEBUG} +{$if defined(EXTDEBUG) or defined(MEMDEBUG)} {$define SHOWUSEDMEM} {$endif} diff --git a/compiler/fmodule.pas b/compiler/fmodule.pas index 3900c06f9c..0d7acf3698 100644 --- a/compiler/fmodule.pas +++ b/compiler/fmodule.pas @@ -209,6 +209,10 @@ implementation scanner,ppu, procinfo; +{$ifdef MEMDEBUG} + var + memsymtable : TMemDebug; +{$endif} {***************************************************************************** Global Functions @@ -445,9 +449,6 @@ implementation destructor tmodule.Destroy; var -{$ifdef MEMDEBUG} - d : tmemdebug; -{$endif} i : longint; hpi : tprocinfo; begin @@ -516,7 +517,7 @@ implementation localincludesearchpath.free; locallibrarysearchpath.free; {$ifdef MEMDEBUG} - d:=tmemdebug.create(modulename^+' - symtable'); + memsymtable.start; {$endif} derefdata.free; deflist.free; @@ -530,7 +531,7 @@ implementation if assigned(localmacrosymtable) then localmacrosymtable.free; {$ifdef MEMDEBUG} - d.free; + memsymtable.stop; {$endif} stringdispose(modulename); inherited Destroy; @@ -846,4 +847,15 @@ implementation end; +initialization +{$ifdef MEMDEBUG} + memsymtable:=TMemDebug.create('Symtables'); + memsymtable.stop; +{$endif MEMDEBUG} + +finalization +{$ifdef MEMDEBUG} + memsymtable.free; +{$endif MEMDEBUG} + end. diff --git a/compiler/ogbase.pas b/compiler/ogbase.pas index e146d2d8ac..d14be0b375 100644 --- a/compiler/ogbase.pas +++ b/compiler/ogbase.pas @@ -740,13 +740,9 @@ implementation destructor TObjData.destroy; -{$ifdef MEMDEBUG} - var - d : tmemdebug; -{$endif} begin + { Symbols } {$ifdef MEMDEBUG} - d:=tmemdebug.create(name+' - ObjData symbols'); MemObjSymbols.Start; {$endif} ResetCachedAsmSymbols; @@ -754,16 +750,14 @@ implementation FObjSymbolList.free; {$ifdef MEMDEBUG} MemObjSymbols.Stop; - d.free; {$endif} + { Sections } {$ifdef MEMDEBUG} - d:=tmemdebug.create(name+' - ObjData sections'); MemObjSections.Start; {$endif} FObjSectionList.free; {$ifdef MEMDEBUG} MemObjSections.Stop; - d.free; {$endif} inherited destroy; end; diff --git a/compiler/symtype.pas b/compiler/symtype.pas index 5d56e90c33..3b8e874042 100644 --- a/compiler/symtype.pas +++ b/compiler/symtype.pas @@ -181,7 +181,6 @@ interface {$ifdef MEMDEBUG} var - memrealnames, memmanglednames, memprocpara, memprocparast, @@ -949,8 +948,6 @@ implementation {$ifdef MEMDEBUG} initialization - memrealnames:=TMemDebug.create('Realnames'); - memrealnames.stop; memmanglednames:=TMemDebug.create('Manglednames'); memmanglednames.stop; memprocpara:=TMemDebug.create('ProcPara'); @@ -963,7 +960,6 @@ initialization memprocnodetree.stop; finalization - memrealnames.free; memmanglednames.free; memprocpara.free; memprocparast.free;