On 6/19/23 12:51 PM, Anonymouse wrote:
On Monday, 19 June 2023 at 16:43:30 UTC, Steven Schveighoffer wrote:

In this specific case, most likely it's a stale register or stack reference. One way I usually use to ensure such things is to call a function that destroys the existing stack:

```d
void clobber()
{
   int[2048] x;
}
```

Calling this function will clear out 2048x4 bytes of data to 0 on the stack.

Could you elaborate on how you use this? When do you call it? Just, ever so often, or is there thought behind it?

Just before forcing a collect.

The stack is *always* scanned conservatively, and even though really the stack data should be blown away by the next function call (probably GC.collect), it doesn't always work out that way. Indeed, even just declaring `x` might not do it if the compiler decides it doesn't actually have to.

But I've found that seems to help.

-Steve

Reply via email to