January 29, 2021
On Thursday, 28 January 2021 at 22:11:40 UTC, tsbockman wrote:

> Alternatively, you can design your APIs so that no pointer to GC memory is ever owned or mutated by any thread unknown to that GC. (This is the only option when working across language boundaries.)

Yes, thank you for your input - I was already thinking about that as it shows the better design and also wouldn't require that the DLL itself build-in much redundant code.

However, if I run GC.collect() after every DLL function was done then it clearly shows which data goes away and bite me. Basically most objects are allocated in the main EXE/DLL anyway - it only comes in trouble where a new separate object is returned by the sub DLL - GC.addRoot() really solves that problem.

January 29, 2021
On Monday, 25 January 2021 at 17:11:37 UTC, frame wrote:
> On Monday, 25 January 2021 at 16:54:42 UTC, vitamin wrote:
>> On Monday, 25 January 2021 at 16:44:40 UTC, frame wrote:
>>> On Monday, 25 January 2021 at 16:14:05 UTC, vitamin wrote:

>
> Yes, I directly calling on every function that returns an object:
>
> T fun(T)(T object) {
>   GC.addRoot(cast(void*) object);
> }
> ...
> extern (C) export SomeObject bar() {
>     return fun(new SomeObject);
> }
>

Just to confirm... I assume you just neglected to show the line in fun template function that returns the object, right?

Like...

T fun(T)(T object) {
  GC.addRoot(cast(void*) object);
  return object;
}
January 29, 2021
On Friday, 29 January 2021 at 15:09:23 UTC, ShadoLight wrote:

> Just to confirm... I assume you just neglected to show the line in fun template function that returns the object, right?

Yes, that's pseudo code with a missed return :D


1 2 3
Next ›   Last »