Allocation & Deallocation

Where?

  • Globals/Data/Text Segment
  • Stack Segment
  • Stack inside a frame
  • Heap Segment
  • Heap inside an object/array
  • Stack frame inside an object/array

Allocation & Deallocation

How?

  • Not allocated
  • Statically allocated
  • Automatically allocated
  • Dynamically allocated
  • Manually deallocated
  • Garbage collected

Allocation & Deallocation

What allocations are possible in what languages?

What / Language Java C++ Python
globals/data/text segment nope yup nope (globals in heap!)
stack frames yup yup yup
primitives inside a frame on stack yup yup yup
constructed/array/object (inside stack frame on stack) nope yup nope
primitive on heap nope yup nope
constructed/array/object on heap yup yup yup
primitives in constructed/array/object (wherever the constructed is located) yup yup yup
constructed/array/object in constructed/array/object (wherever the constructed is located) yup yup yup