consider this :

struct S
{
/* ... */

}

void main()
{
   ulong [] u;

   for(// ...
   {
      S s_instance;
      // fillup .. S.key = value;
      u ~= cast(ulong)*s_instance;
   }

}

however, the structs are being allocated to the same place. Because, Every time the iterator ends an iteration, seemingly, s_instance is collected as garbage.

A test produces output like this.
object : a of type : tensor is stored at : 140737373264752
object : b of type : tensor is stored at : 140737373264752
object : c of type : tensor is stored at : 140737373264752
object : d of type : tensor is stored at : 140737373264752

So I would like to know if there is a malloc alternative in D, which I can use to explicitely allocate memory to hold a struct, or any other variable , such that the garbage collector does not remove it automatically.



Reply via email to