alogrep 0 Posted October 27, 2020 Hi, I have a component with is derived from the Tcomponent class and is basically a table with cells. Each cells contains a text, a Tcolor and a TObject (which is always a TObject(integer). Randomly I an AV error and when I check on the component, the component is NIL. I cannot trace back to where/what overwrote the memory. Madexcept does not catch the AV even with the buffer overrun checked. My endless Google search shows me lots of memory LEAKS but very little on memory overwrite. Anybody knows of a good tool that would help catch the overwrite excacly where and when it happens? Thanks Share this post Link to post
Jacek Laskowski 57 Posted October 27, 2020 FastMM in full debug mode + properly configured .inc file Share this post Link to post
alogrep 0 Posted October 27, 2020 Thanks. Waiting for the error to occur, to see if fastmm catches it. Share this post Link to post
alogrep 0 Posted October 28, 2020 Uhm. The error happened, but Fastmm4 tells me all about memory leaks, nothing about memory overwrite. It shows a complete list of allocations for the table cells, and all allocations are shown as memory leaks because the table is somehow overwritten (and becomes NIL), and therefore the Destructor is not called. It gives me no clue as to what function exactly overwrite the table. Share this post Link to post
Remy Lebeau 1393 Posted October 29, 2020 16 hours ago, alogrep said: the table is somehow overwritten (and becomes NIL), and therefore the Destructor is not called. It gives me no clue as to what function exactly overwrite the table. Run the component code in the debugger, and put a DATA BREAKPOINT on the pointer variable that is turning nil unexpectedly, and when the breakpoint is hit then look at the call stack to see who is setting the pointer to nil. 1 Share this post Link to post
alogrep 0 Posted October 29, 2020 Thanks Remy. The tables are created, populated and freed dynamically. Te component class is Tslim. Then according to what I need I do table1:=Tslim.Create; table2:=Tslim.create etc. Is it possible to put a databreakpoint on a class as opposed to a variable? How? Share this post Link to post
Kryvich 165 Posted October 29, 2020 Have you set the overflow and range checking in the project options? Share this post Link to post
Cristian Peța 103 Posted October 29, 2020 (edited) 2 hours ago, alogrep said: table1:=Tslim.Create You told as that a component is becoming nil. Nil can be a reference to an instance of a class (namely a variable), not a class itself. If table1 is that component that is becoming nil then put a data breakpoint on table1. More exactly on table1's address (namely @table1). But it is enough to write table1 into the addresses field of "Add Data Breakpoint" dialog. @Remy Lebeau thank you very match for this. I needed a data breakpoint sometimes but I didn't know they actually exists. Edited October 29, 2020 by Cristian Peța Share this post Link to post
Kryvich 165 Posted October 29, 2020 Where do you store reference variables for the tables? I.e. table1, table2 etc. Share this post Link to post