In the past I asked Adam about when I should use keyword `new` with structures and got next answer:

"The File in the first one is put on the stack as a reference counted local object whereas the second one would be on the garbage collected heap, which often isn't what you want for files since you want to close
them when you're done.

Generally, D's structs often work best without the `new` keyword since
they can be made in place."

But I have read that stack size is very limited I tried to test two variants of reading big (20MB) text file:

auto file = File("test.txt", "r");
and
auto file = new File("test.txt", "r");

Tests does not show any significant difference in performance. But I still not understand where the data is location in first variant?

Reply via email to