Newbie questions on memory allocation

Deokjae Lee asitdepends at gmail.com
Sat Jul 24 08:04:29 PDT 2010


Hi there, I have some questions on the following code.

import std.stdio;

struct S {
	int x;
}

void main() {
	int[3] a = new int[3];//A
	S* b = new S();//B
	delete b;//C
}

What's the meaning of the line A?
Is the array allocated on heap? or stack?
Is it dynamic or static?

I think the line B is not a good style in D, but anyway I have a question.
Does the garbage collector concern the object constructed at line B?
Is the line C safe?


More information about the Digitalmars-d-learn mailing list