Dangling Pointers lazarus / 12-Debugger ---------------------------------------------------------------------- skiy1337lazarus · 2015-03-28 11:31 begin O.Free; Caption := IntToStr(O.Field); {This would work if you ran it. I propose adding an option to Project Options that makes this display incorrect output. (see attachment) The idea is to have a memory manager where: - Instead of FreeMem, FillChar is called to corrupt the memory. - More and more memory is used until a certain limit. This would be for debug mode only. ---------------------------------------------------------------------- eny · 2015-03-28 12:54 FreeAndNil(O) ---------------------------------------------------------------------- skiy1337lazarus · 2015-03-28 13:34 I used to use FreeAndNil a lot. ---------------------------------------------------------------------- BeniBela · 2015-03-28 13:57 -CR ? ---------------------------------------------------------------------- skiy1337lazarus · 2015-03-28 14:14 -cR for range checking? I know there is also a verify method calls option. I will try -cR now, but I don't think it will work. ---------------------------------------------------------------------- BeniBela · 2015-03-28 14:28 The verify method option. Range checking would be -Cr ---------------------------------------------------------------------- Martin_fr · 2015-03-28 15:32 First of all, this is not a debugger issue, but a compiler issue. Of course it is for debugging, but it must be implemented in the compiler (in fpc itself)). Second, most of this exists. Of course even if  (as you say) you fill the memory with some trash, your code still runs. The caption will just be 98979234 or something. -gh (to use heaptrc) will trash the memory. But by default it will not be kept. That is kept by the mem manager, but it will be re-used as soon as you do anything that needs to allocate memory (and can fit into the size of the freed mem) Heaptrc also checksums the memory, so if you write to it, that will be detected, albeit, only later usually when the app exits I do not know the link to heaptrc doc, but you can set environment [1], to change some option, including keeping memory  (though that means keep forever). HEAPTRC=keepreleased There are more options. You can also trash uninitialized variables (with different values) using -gt or -gtt or -gttt [1] Note that gdb 7.2 (default on win) has a bug and setting environment does not work. Download 7.7.1 from the Lazarus Sourceforce site. ---------------------------------------------------------------------- skiy1337lazarus · 2015-03-28 16:48 Thank you so much. I am going to print that out. No one knows about it!