Per thread heap, GC, etc.

Markk markus.kuehni at triviso.ch
Fri May 14 18:39:41 UTC 2021


On Friday, 14 May 2021 at 17:13:00 UTC, IGotD- wrote:
> On Friday, 14 May 2021 at 17:02:00 UTC, Markk wrote:
>
> If for example C++ calls a D function, the D function does 
> something temporary with arrays then those arrays will not be 
> cleaned up if the array memory is thread local.

First of all, if the D function lives in the C++ thread (i.e. 
normal callback) then it inherits the memory management of the 
C++ thread (e.g. non-GC) and would have to behave accordingly. 
The situation is much better than today, where the C++ thread 
punches into the D memory managed world, and it is solely the 
developers' responsibility to make sure not to return GC'd memory 
back to the C++ thread. The language guarantees (I described in 
the initial post) would make sure that nothing illegal can leak 
back into C++ by disallowing memory references from other (GC'd) 
threads.

If however the C++ call wanted to pass memory to/from other D 
threads, It could do so via message passing. Everything is 
properly managed and accounted for, by the thread separation.

_Mark




More information about the Digitalmars-d mailing list