d malloc
seany via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Aug 8 09:42:12 PDT 2014
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.
More information about the Digitalmars-d-learn
mailing list