Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Are there guidelines concerning stack usage? Stack versus heap?

guidelines heap stack usage versus
0
0 Posted

Are there guidelines concerning stack usage? Stack versus heap?

0
0

Unlike Java, C and C++ are able to instantiate a lot more data [objects] on stack. Typically data that has function-body lifetime should be realized on the stack; data that has dynamic extent (i.e. that is returned to calling functions [not by-value] and referenced there) must be allocated on heap. The heap can be used too (the Java way) if there exist [severe] stack size restrictions. Static data should not be applied [in that or other cases], since that makes a function non-reentrant [see question on reentrancy].

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123