Account for live allocation sizes

A C analysis routine begins with no dynamically allocated storage and performs these events in order. Every allocation and resize succeeds. An integer occupies 4 bytes and a double occupies 8 bytes. Ignore allocator overhead and any temporary internal storage used during resizing.

  • Stage A: Allocate an array of 7 integers.
  • Stage B: Allocate a separate array of 11 doubles, retaining the integer array.
  • Stage C: Release the integer array.
  • Stage D: Resize the double array to 15 elements, retaining the returned pointer.
  • Stage E: Release the resized double array.

Complete the table with the total requested bytes in live allocations immediately after each stage finishes. Enter exact integers in bytes.

StageTotal live bytes
A
B
C
D
E

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Dynamic Memory Questions: