uwhpsc-2016 / lectures

Notes, slides, and code from the in-class lectures.
7 stars 21 forks source link

Runtime vs. Compiletime ... again #20

Open gadamico opened 8 years ago

gadamico commented 8 years ago

So I'm a little confused, again / still, about dynamic memory allocation. I ended up using the stack to allocate my variables in HW 2, but ... well ... I'm not quite sure why that was possible!

Since N, an input to lots of our linear algebra functions, is determined at runtime (?), shouldn't that mean that the parameters depending for their size on N would have to be heap-allocated?

cswiercz commented 8 years ago

See this thread: https://github.com/uwhpsc-2016/lectures/issues/5

One main difference is that (by default) you cannot allocate as much memory on the stack as on the heap.

cswiercz commented 8 years ago

Another main difference: it's faster to reference stack allocations than heap allocations.