MemCheck tutorial: find bad calls
- In MemCheck, set DeallocateFreedMemoryWhenBlockBiggerThan to a reasonnable
value, eg MaxInt (this value is not reasonnable if your program allocates very big spaces,
eg big vectors - then choose for example 1000)
- In MemCheck set WipeOutMemoryOnFreeMem to true
- Define a class TMyObject
TMyObject = class
procedure p; virtual;
end;
- Define TMyObject with an empty body
- Add a procedure BadCall
procedure BadCall;
var
t: TMyObject;
begin
t:= TMyObject.Create;
t.Destroy;
t.p;
end;
- In the dpr's body, just call BadCall
begin
MemChk;
BadCall;
end.
- When you run the program, MemCheck will tell you you are calling P after the object has
been destroyed. Better than an access violation, no ? And this is very useful for double
destructions.
Last update: March 2001