Per thread heap, GC, etc.
H. S. Teoh
hsteoh at quickfur.ath.cx
Fri May 14 16:11:26 UTC 2021
On Fri, May 14, 2021 at 01:48:12PM +0000, Markk via Digitalmars-d wrote:
[...]
> D has this nice default per-thread static memory model, i.e. if I
> understand all this correctly, this allows for better, more natural
> thread safety, while it makes it generally unsafe to use this memory
> from other threads (without locking). I guess the same is implicitly
> true for stack memory.
>
> Now could it equally make sense to use per-thread heaps?
It would be nice, because it would allow per-thread GC, which could
address some of the problems people complain about the GC.
However, there's a big caveat: sharing data between threads would be
essentially extremely broken. Today, immutable can be safely shared
across threads, because well, it's immutable. But once allocations are
bound to a thread, this sharing would be impossible without major
problems.
> I.e. all allocations would need to be per thread, and it would be
> illegal to reference memory of one thread's heap, static memory, or
> stack from another thread's memory.
[...]
Yeah, this would be a major bugbear for implementing it in D.
T
--
If creativity is stifled by rigid discipline, then it is not true creativity.
More information about the Digitalmars-d
mailing list