Either I'm confused or the gc is

donallen donaldcallen at gmail.com
Thu Oct 22 04:12:30 UTC 2020


On Thursday, 22 October 2020 at 01:30:41 UTC, ketmar wrote:
> donallen wrote:
>
>> But working with gdb, I found that the account structs after 
>> the error messages start are zeroed.
> GC should not zero any memory by itself (it doesn't "clear" 
> freed chunks). it looks like the GC is reusing the allocated 
> memory.

The thought did occur to me as well that the zeroing probably 
occurs on allocation, but I don't see how you get from that to 
the behavior I'm observing, since the children array gets  
populated with data right after allocation. It appears that the 
Account structs being passed in the recursive calls to 
walk_account_tree, which are elements of the children array, are 
zeroed.

>
> you can use `core.memory.GC.addrOf()` to check if your pointers 
> are still "alive". you can add calls to `addrOf()` before 
> processing a data, it may help to catch the moment data is 
> incorrectly freed (if that happens).

I'll give this a try tomorrow. Thanks.




More information about the Digitalmars-d mailing list