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. Any garbage collector would suffer here because it would look at the register and think that the memory is accessible. 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. Hamad > On May 16, 2019, at 08:46, Andrew Haley <aph@xxxxxxxxxx> wrote: > >> On 5/14/19 3:31 PM, Hamad Ahmed wrote: >> Should not be too hard to put in? Gcc does know when >> a variable won’t be used anymore. So you coul compile with something >> like -fgarbage so it inserts an extra assembly instruction >> that zeros out those registers containing pointers to these >> dead variables. > > 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. > > -- > 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