[haiku] Heap vs Stack

  • From: Scott Kemp <kemps4@xxxxxxxxxxxx>
  • To: haiku@xxxxxxxxxxxxx
  • Date: Thu, 9 Aug 2012 14:58:58 -0400

I'm sure this is a simple question for most - but when should a programmer
store information in the heap versus the stack.  Am I right to assume that
normally a local variable could be stored in the stack and a global
variable or maybe an array would be better in the heap?

Also I'm reading that the stack has a smaller, limited capacity.  How large
is the stack normally, does it vary by OS or environment?  Can I check for
free heap and stack memory?

Thanks,
Scott

Other related posts: