°æ¿éµ¼º½
ÕýÔÚ¼ÓÔØÖÐ...
¿Í»§¶ËAPPÏÂÔØ
ÂÛÎĸ¨µ¼
µ÷¼ÁС³ÌÐò
怬
×¢²á
Ìû×Ó
Ìû×Ó
Óû§
±¾°æ
Ó¦¡¶ÍøÂ簲ȫ·¨¡·ÒªÇó£¬×Ô2017Äê10ÔÂ1ÈÕÆð£¬Î´½øÐÐʵÃûÈÏÖ¤½«²»µÃʹÓû¥ÁªÍø¸úÌû·þÎñ¡£Îª±£ÕÏÄúµÄÕʺÅÄܹ»Õý³£Ê¹Óã¬Ç뾡¿ì¶ÔÕʺŽøÐÐÊÖ»úºÅÑéÖ¤£¬¸ÐлÄúµÄÀí½âÓëÖ§³Ö£¡
24СʱÈÈÃŰæ¿éÅÅÐаñ
>
ÂÛ̳¸üÐÂÈÕÖ¾
(4281)
>
¿¼ÑÐ
(1878)
>
µ¼Ê¦ÕÐÉú
(1459)
>
ÎÄÏ×ÇóÖú
(344)
>
˶²©¼ÒÔ°
(130)
>
³æÓÑ»¥Ê¶
(120)
>
¿¼²©
(88)
>
ÕÐÆ¸ÐÅÏ¢²¼¸æÀ¸
(86)
>
ÐÝÏйàË®
(75)
>
ÂÛÎÄͶ¸å
(67)
>
²©ºóÖ®¼Ò
(54)
>
¹¥¹ØÎÄÏ×(¸ß½±Àø)
(40)
>
ÂÌÉ«ÇóÖú(¸ßÐüÉÍ)
(35)
>
»ù½ðÉêÇë
(33)
>
¹«Åɳö¹ú
(28)
>
ÍâÎÄÊé¼®ÇóÖú
(27)
Сľ³æÂÛ̳-ѧÊõ¿ÆÑл¥¶¯Æ½Ì¨
»
¼ÆËãÄ£ÄâÇø
»
³ÌÐòÓïÑÔ
»
Delphi&Pascal
»
¡¾×ªÌû¡¿delphiÖÐÈçºÎ¼ì²âÄÚ´æÍ¸Â¶(null)
1
1/1
·µ»ØÁбí
²é¿´: 477 | »Ø¸´: 0
Ö»¿´Â¥Ö÷
@ËûÈË
´æµµ
лظ´ÌáÐÑ
(ºöÂÔ)
ÊÕ²Ø
ÔÚAPPÖв鿴
zyj8119
ľ³æ
(ÖøÃûдÊÖ)
Ó¦Öú: 65
(³õÖÐÉú)
¹ó±ö: 0.003
½ð±Ò: 915.1
É¢½ð: 1440
ºì»¨: 35
Ìû×Ó: 2936
ÔÚÏß: 1329.4Сʱ
³æºÅ: 664177
×¢²á: 2008-11-29
ÐÔ±ð: GG
רҵ: ÀíÂۺͼÆË㻯ѧ
[½»Á÷]
¡¾×ªÌû¡¿delphiÖÐÈçºÎ¼ì²âÄÚ´æÍ¸Â¶(null)
ÊÔÊÔżÕâ¸öÄÚ´æÓ¦Óà ¼à¶½ Æ÷
Ó÷¨·Ç³£¼òÂÔ £¬ÔÚÄãµÄproject sourceÀï°Ñ
ÀûÓà Õâ¸öµ¥ÔªµÄÄǾä·Åµ½×îǰ£¬Èç
...
CODE:
uses
MemoryManager in '...pas',
Forms,
Main in 'Main.pas' {frmMain},
...
ÐÞÕý ×ÔDelphi Developer's Handbook¡¡
´úÂëÈçÏ¡¡
unit MemoryManager;
interface
var
GetMemCount: Integer = 0;
FreeMemCount: Integer = 0;
ReallocMemCount: Integer = 0;
var
mmPopupMsgDlg: Boolean = True;
mmSaveToLogFile: Boolean = True;
mmErrLogFile: string = '';
¡¡
procedure SnapToFile(Filename: string);
implementation
uses
Windows, SysUtils, TypInfo;
const
MaxCount = High(Word);
var
OldMemMgr: TMemoryManager;
ObjList: array[0..MaxCount] of Pointer;
FreeInList: Integer = 0;
procedure AddToList(P: Pointer);
begin
if FreeInList > High(ObjList) then
begin
MessageBox(0, 'ÄÚ´æ¹ÜÀí¼à¶½ Æ÷Ö¸ÕëÁбíÒç³ö£¬ÇëÔö´óÁбíÏîÊý£¡', 'ÄÚ´æ¹ÜÀí¼à¶½ Æ÷', mb_ok);
Exit;
end;
ObjList[FreeInList] := P;
Inc(FreeInList);
end;
procedure RemoveFromList(P: Pointer);
var
I: Integer;
begin
for I := 0 to FreeInList - 1 do
if ObjList[I] = P then
begin
Dec(FreeInList);
Move(ObjList[I + 1], ObjList[I], (FreeInList - I) * SizeOf(Pointer));
Exit;
end;
end;
procedure SnapToFile(Filename: string);
var
OutFile: TextFile;
I, CurrFree, BlockSize: Integer;
HeapStatus: THeapStatus;
Item: TObject;
ptd: PTypeData;
ppi: PPropInfo;
begin
AssignFile(OutFile, Filename);
try
if FileExists(Filename) then
Append(OutFile)
else
Rewrite(OutFile);
CurrFree := FreeInList;
HeapStatus := GetHeapStatus; { ¾Ö²¿¶Ñ״̬ }
with HeapStatus do
begin
writeln(OutFile, '--');
writeln(OutFile, DateTimeToStr(Now));
writeln(OutFile);
write(OutFile, '¿ÉÓõØÖ·¿Õ¼ä : ');
write(OutFile, TotalAddrSpace div 1024);
writeln(OutFile, ' ǧ×Ö½Ú');
write(OutFile, 'δÌá½»²¿·Ö : ');
write(OutFile, TotalUncommitted div 1024);
writeln(OutFile, ' ǧ×Ö½Ú');
write(OutFile, 'ÒÑÌá½»²¿·Ö : ');
write(OutFile, TotalCommitted div 1024);
writeln(OutFile, ' ǧ×Ö½Ú');
write(OutFile, '¿ÕÏв¿·Ö : ');
write(OutFile, TotalFree div 1024);
writeln(OutFile, ' ǧ×Ö½Ú');
write(OutFile, 'ÒÑ·ÖÅ䲿·Ö : ');
write(OutFile, TotalAllocated div 1024);
writeln(OutFile, ' ǧ×Ö½Ú');
write(OutFile, 'µØÖ·¿Õ¼äÔØÈë : ');
write(OutFile, TotalAllocated div (TotalAddrSpace div 100));
writeln(OutFile, '%');
write(OutFile, 'Õû¸ö С¿ÕÏÐÄÚ´æ¿é : ');
write(OutFile, FreeSmall div 1024);
writeln(OutFile, ' ǧ×Ö½Ú');
write(OutFile, 'Õû¸ö ´ó¿ÕÏÐÄÚ´æ¿é : ');
write(OutFile, FreeBig div 1024);
writeln(OutFile, ' ǧ×Ö½Ú');
write(OutFile, 'ÆäËüδÓÃÄÚ´æ¿é : ');
write(OutFile, Unused div 1024);
writeln(OutFile, ' ǧ×Ö½Ú');
write(OutFile, 'ÄÚ´æ¹ÜÀíÆ÷ºÄËð : ');
write(OutFile, Overhead div 1024);
writeln(OutFile, ' ǧ×Ö½Ú');
end;
writeln(OutFile);
write(OutFile, 'ÄÚ´æ¶ÔÏóÊýÄ¿ : ');
writeln(OutFile, CurrFree);
for I := 0 to CurrFree - 1 do
begin
write(OutFile, I: 4);
write(OutFile, ') ');
write(OutFile, IntToHex(Cardinal(ObjList[I]), 16));
write(OutFile, ' - ');
BlockSize := PDWORD(DWORD(ObjList[I]) - 4)^;
write(OutFile, BlockSize: 4);
write(OutFile, '($' + IntToHex(BlockSize, 4) + ')×Ö½Ú');
write(OutFile, ' - ');
try
Item := TObject(ObjList[I]);
// code not reliable
{ write (OutFile, Item.ClassName);
write (OutFile, ' (');
write (OutFile, IntToStr (Item.InstanceSize));
write (OutFile, ' bytes)');}
// type info technique
if PTypeInfo(Item.ClassInfo).Kind <> tkClass then
write(OutFile, '²»ÊǶÔÏó')
else
begin
ptd := GetTypeData(PTypeInfo(Item.ClassInfo));
// name, Èç¹ûÊÇTComponent
ppi := GetPropInfo(PTypeInfo(Item.ClassInfo), 'Name');
if ppi <> nil then
begin
write(OutFile, GetStrProp(Item, ppi));
write(OutFile, ' : ');
end
else
write(OutFile, '(δÃüÃû): ');
write(OutFile, PTypeInfo(Item.ClassInfo).Name);
write(OutFile, ' (');
write(OutFile, ptd.ClassType.InstanceSize);
write(OutFile, ' ×Ö½Ú) - In ');
write(OutFile, ptd.UnitName);
write(OutFile, '.pas');
end
except
on Exception do
write(OutFile, '²»ÊǶÔÏó');
end;
writeln(OutFile);
end;
finally
CloseFile(OutFile);
end;
end;
function NewGetMem(Size: Integer): Pointer;
begin
Inc(GetMemCount);
Result := OldMemMgr.GetMem(Size);
AddToList(Result);
end;
function NewFreeMem(P: Pointer): Integer;
begin
Inc(FreeMemCount);
Result := OldMemMgr.FreeMem(P);
RemoveFromList(P);
end;
function NewReallocMem(P: Pointer; Size: Integer): Pointer; begin
Inc(ReallocMemCount);
Result := OldMemMgr.ReallocMem(P, Size);
RemoveFromList(P);
AddToList(Result);
end;
const
NewMemMgr: TMemoryManager = (
GetMem: NewGetMem;
FreeMem: NewFreeMem;
ReallocMem: NewReallocMem);
initialization
GetMemoryManager(OldMemMgr);
SetMemoryManager(NewMemMgr);
finalization
SetMemoryManager(OldMemMgr);
if (GetMemCount - FreeMemCount) <> 0 then
begin
if mmPopupMsgDlg then
MessageBox(0, PChar(Format('³öÏÖ%d´¦ÄÚ´æÂ©¶´: ',
[GetMemCount - FreeMemCount])), 'ÄÚ´æ¹ÜÀí¼à¶½ Æ÷', mb_ok);
if mmErrLogFile = '' then
mmErrLogFile := ExtractFileDir(ParamStr(0)) + '.Log';
if mmSaveToLogFile then
SnapToFile(mmErrLogFile);
end;
end.
»Ø¸´´ËÂ¥
» ²ÂÄãϲ»¶
314Çóµ÷¼Á
ÒѾÓÐ5È˻ظ´
314Çóµ÷¼Á
ÒѾÓÐ11È˻ظ´
»¹Óл¯¹¤¶þÂÖµ÷¼ÁµÄѧУÂð
ÒѾÓÐ28È˻ظ´
²ÄÁÏ»¯¹¤×Ü·Ö334Çóµ÷¼Á
ÒѾÓÐ12È˻ظ´
296Çóµ÷¼Á
ÒѾÓÐ5È˻ظ´
297Çóµ÷¼Á
ÒѾÓÐ14È˻ظ´
¿¼ÑжþÂÖµ÷¼Á
ÒѾÓÐ5È˻ظ´
Çó»úеר˶297µÚ¶þÅúµ÷¼Á
ÒѾÓÐ5È˻ظ´
±¾¿ÆÖ£ÖÝ´óѧ£¬Ò»Ö¾Ô¸»ª¶«Ê¦·¶´óѧ282Çóµ÷¼Á
ÒѾÓÐ25È˻ظ´
283Çóµ÷¼Á
ÒѾÓÐ6È˻ظ´
¸ß¼¶»Ø¸´
ºÃºÃѧϰ£¬ÌìÌìÏòÉÏ¡£
1Â¥
2010-12-02 16:29:32
ÒÑÔÄ
»Ø¸´´ËÂ¥
¹Ø×¢TA
¸øTA·¢ÏûÏ¢
ËÍTAºì»¨
TAµÄ»ØÌû
Ïà¹Ø°æ¿éÌø×ª
µÚÒ»ÐÔÔÀí
Á¿×Ó»¯Ñ§
¼ÆËãÄ£Äâ
·Ö×ÓÄ£Äâ
·ÂտģÄâ
³ÌÐòÓïÑÔ
ÎÒÒª¶©ÔÄÂ¥Ö÷
zyj8119
µÄÖ÷Ìâ¸üÐÂ
1
1/1
·µ»ØÁбí
Èç¹û»ØÌûÄÚÈݺ¬ÓÐÐû´«ÐÅÏ¢£¬ÇëÈçʵѡÖС£·ñÔòÕʺŽ«±»È«ÂÛ̳½ûÑÔ
ÆÕͨ±íÇé
Áú
ÍÃ
Ȣ
è
¸ß¼¶»Ø¸´
(¿ÉÉÏ´«¸½¼þ)
°Ù¶ÈÍøÅÌ
|
360ÔÆÅÌ
|
ǧÒ×ÍøÅÌ
|
»ªÎªÍøÅÌ
ÔÚд°¿ÚÒ³ÃæÖдò¿ª×Ô¼ºÏ²»¶µÄÍøÅÌÍøÕ¾£¬½«ÎļþÉÏ´«ºó£¬È»ºó½«ÏÂÔØÁ´½Ó¸´ÖƵ½Ìû×ÓÄÚÈÝÖоͿÉÒÔÁË¡£
×î¾ßÈËÆøÈÈÌûÍÆ¼ö
[²é¿´È«²¿]
×÷Õß
»Ø/¿´
×îºó·¢±í
[
¿¼ÑÐ
]
²ÄÁϵ÷¼Á
+14
Ò»ÑùYWY
2026-04-06
14/700
2026-04-08 23:00
by
Öí»á·É
[
¿¼ÑÐ
]
Ò»Ö¾Ô¸211£¬»¯Ñ§Ñ§Ë¶£¬310·Ö£¬±¾¿ÆÖصãË«·Ç£¬Çóµ÷¼Á
+15
ŬÁ¦·Ü¶·112
2026-04-06
17/850
2026-04-08 22:27
by
¿¿Òª±ä˧
[
¿¼ÑÐ
]
285Çóµ÷¼Á
+12
AZMK
2026-04-05
18/900
2026-04-08 20:43
by
ÄæË®³Ë·ç
[
¿¼ÑÐ
]
277Çóµ÷¼Á
+4
¿¼Ñе÷¼Álxh
2026-04-06
6/300
2026-04-08 10:40
by
ÄæË®³Ë·ç
[
¿¼ÑÐ
]
283·ÖÇóµ÷¼Á
+14
ÊÔÊÔ¿´ßÂ
2026-04-04
14/700
2026-04-08 07:03
by
lijunpoly
[
¿¼ÑÐ
]
²ÄÁϵ÷¼Á
+13
ºº123456
2026-04-07
14/700
2026-04-07 22:53
by
À´¿´Á÷ÐÇÓê10
[
¿¼ÑÐ
]
²ÄÁϹ¤³Ì302·ÖÇóµ÷¼Á
+13
zyxÉϰ¶£¡
2026-04-04
13/650
2026-04-07 11:14
by
Ê«Óë×ÔÓÉ
[
¿¼ÑÐ
]
334·Ö¿ØÖƹ¤³ÌÇóµ÷¼Á
+4
½ªÉÐÕæsadasd
2026-04-03
4/200
2026-04-07 09:26
by
À¶ÔÆË¼Óê
[
¿¼ÑÐ
]
²ÄÁÏÓ뻯¹¤371Çóµ÷¼Á
+14
ÅãÁÕ¿´º£
2026-04-04
15/750
2026-04-06 06:59
by
houyaoxu
[
¿¼ÑÐ
]
¿¼Ñе÷¼Á
+5
ÃÀÀöµÄyouth_
2026-04-04
6/300
2026-04-06 06:57
by
houyaoxu
[
¿¼ÑÐ
]
306·Ö²ÄÁÏÓ뻯¹¤Çóµ÷¼Á
+7
Àè°ÉÀ²À²ÄãºÜÓÐÃ
2026-04-03
7/350
2026-04-05 17:18
by
Hdyxbekcb
[
¿¼ÑÐ
]
313Çóµ÷¼Á
+5
º£ÈÕº£ÈÕ
2026-04-04
7/350
2026-04-05 13:58
by
imissbao
[
¿¼ÑÐ
]
290Çóµ÷¼Á
+7
luoziheng
2026-04-04
7/350
2026-04-04 23:17
by
lqwchd
[
¿¼ÑÐ
]
µ÷¼Á
+9
19945159693
2026-04-03
10/500
2026-04-04 20:16
by
dongzh2009
[
¿¼ÑÐ
]
368Çóµ÷¼Á
+5
½ñ»ªÏ°
2026-04-03
7/350
2026-04-04 18:47
by
imissbao
[
¿¼ÑÐ
]
22408Çóµ÷¼Á 354·Ö ¿É¿çרҵ
+3
hannnnnnn
2026-04-04
3/150
2026-04-04 14:35
by
ÍÁľ˶ʿÕÐÉú
[
¿¼ÑÐ
]
335Çóµ÷¼Á
+7
ÉòÇåÁ§
2026-04-03
7/350
2026-04-03 18:55
by
lijunpoly
[
¿¼ÑÐ
]
¿¼Ñе÷¼Á
+3
Draa
2026-04-03
3/150
2026-04-03 17:37
by
hgwz7468
[
¿¼ÑÐ
]
338Çóµ÷¼Á
+7
êɹ¦?
2026-04-03
7/350
2026-04-03 16:46
by
wxiongid
[
¿¼ÑÐ
]
ÍÁľˮÀû328·ÖÇóµ÷¼Á
+6
¼²·çÖª¾¢²Ý666
2026-04-02
6/300
2026-04-03 11:38
by
znian
ÐÅÏ¢Ìáʾ
¹Ø±Õ
ÇëÌî´¦ÀíÒâ¼û
¹Ø±Õ
È·¶¨