Every programmer already has experienced access violations which have been caused by prematurely freed memory. These bugs sometimes can be very hard to find as the error might have been happened some long time before.
DDDebug can help you isolate those problems with its MemoryItemWatcher. The following snippet illustrates its usage:
lWatcher := TDDDMemoryItemWatcher.GetInstance; GetMemoryProfiler.Active := True; lStrings := TStringList.Create; try lWatcher.Watch(lStrings); // ... lWatcher.Unwatch(lStrings); finally FreeAndNil(lStrings); end;
If the watched string list will be freed somewhere within the call of Watch and Unwatch the MemoryItemWatcher will raise an exception or stop on a break point which notifies the debugger thus enabling isolation of the problem.