What should happen here?
Steven Schveighoffer
schveiguy at gmail.com
Mon Sep 27 15:10:12 UTC 2021
On 9/27/21 10:39 AM, Max Samukha wrote:
> On Monday, 27 September 2021 at 13:59:57 UTC, Steven Schveighoffer wrote:
>
>>
>> What I'm saying is, *if* you need a specific address saved for later
>> in a function, wouldn't you prefer to store that on the stack rather
>> than store it in the GC's roots? This would absolutely be opt-in, not
>> automatic, as I don't see how we can do it automatically.
>>
>
> If performance was important, you would want to allocate the object
> itself on the stack? The cost of GC allocation outweighs that of
> GC.addRoot by a lot.
>
>
That's not as @safe, but it can be a viable option, as long as your
object is constructed within your function and not in a factory function.
-Steve
More information about the Digitalmars-d
mailing list