On 5/17/19 3:55 PM, Hamad Ahmed wrote: > Its not the collector’s imprecision that’s the problem here. Boehm > GC is conservative i.e. if an integer in the memory looks like a > pointer to memory then that memory is leaked. The problem here is > that gcc leaves dead pointers in registers and doesn’t overwrite > them if there isn’t a lot of register pressure. Yes. > Any garbage collector would suffer here because it would look at the > register and think that the memory is accessible. Yes. This happens with many garbage collectors. It happens in Java implementations too, even though they have precise GC. Collection is only guaranteed to happen eventually, and that might not be until the program exits. > The garbage collector obviously cannot communicate with the compiler to find > out if a variable is dead. That’s why I am asking > that there should be a nice feature where you > compile with a flag like -fgarbage that does register blackholing. Did you not see >> Possibly, but there are several passes of dead code elimination and >> each time the zeroing instruction would be deleted. Bohem is a >> conservative GC, not a precise one, and you have to live with the >> consequences of that. ? You'd have to go through GCC and specially tag all the zeroing instructions and stop them from being moved, even though (from the compiler's point of view) they have no effect on the code. -- Andrew Haley Java Platform Lead Engineer Red Hat UK Ltd. <https://www.redhat.com> https://keybase.io/andrewhaley EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671