Understanding GC memory ranges and roots

Steven Schveighoffer schveiguy at gmail.com
Wed Jul 8 00:23:28 UTC 2020


On 7/7/20 6:36 PM, rikki cattermole wrote:
> On 07/07/2020 11:50 PM, Steven Schveighoffer wrote:
>> If you are adding prints, you may as well throw an exception, catch 
>> it, and print the stack trace if you want to know who's calling what.
> 
> You won't be able to new the Exception tho.
> It'll have to be malloc'd ext.

there are ways to allocate them on the stack as well, or you can simply 
initialize a static exception.

scope Exception ex = new Exception("nothing");
try {
    throw ex;
} catch(Exception e)
{
    // print stack trace
}

> In GC -> lock probably hit -> new -> wait on lock

Not sure, possibly printing the stack trace may be a problem as well. 
But it does seem like it should be doable.

-Steve


More information about the Digitalmars-d mailing list