memory allocation using new

When we allocate memory using new, where it is allocated in heap or stack?

Please tell me the difference between heap and stack?
Officially neither, but implementations can use a heap.

http://www.gotw.ca/gotw/009.htm
closed account (z05DSL3A)
new allocates to the heap.


As a counter to Herb Sutter Free-store versus Heap:
http://zamanbakshifirst.blogspot.co.uk/2007/02/c-free-store-versus-heap.html

0xFFFF╔═════════════════╗           
      ║  Stack Frames   ║ Grows
      ╟─ ─ ─ ─ ─ ─ ─ ─ ─╢   │
      ╟─ ─ ─ ─ ─ ─ ─ ─ ─╢   │
      ╟─ ─ ─ ─ ─ ─ ─ ─ ─╢   ▼
      ╠═════════════════╣
      ║░░░░░░░░░░░░░░░░░║
      ║░Unalocated mem░░║
      ║░░░░░░░░░░░░░░░░░║
      ╠═════════════════╣   ▲
      ╟─ ░ ─ ─ ─ ─ ─ ░ ─╢   │
      ╟─ ─ The HEAP  ─ ─╢   │
      ╟─ ─ ░ ─ ─ ░ ─░─ ─╢ Grows
      ╠═════════════════╣
      ║  Constant Data  ║
      ╠═════════════════╣
      ║  Program Code   ║
      ╠═════════════════╣
0x0000╚═════════════════╝
Last edited on by Canis lupus
Topic archived. No new replies allowed.