memory allocation Flashcards

1
Q

static allocation def

A

programs needing a FIXED amt of memory space & continually reusing it till program terminates

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

dynamic allocation def

A

data needed by program not alw fixed size, program will req for more memory whenever required

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

static > dynamic

A
  • enjoy faster constant-time access to data (while dynamic data structures need to be walked to discover the memory address of other memory blocks)
  • allows binary search, more efficient than linear search (application)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

dynamic > static

A

more efficient memory use (memory can be allocated / de-allocated as needed during runtime as data structure grows / shrinks so it only uses as much memory as necessary while static might not use all memory that’s allocated)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

disadvantage / problem of dynamic data structure

A
  • higher overhead bc allocated blocks also need store pointers to other blocks (context)
  • may run out of memory if total amt of memory used by data structure is not tracked when handling ALOT of data bc OS may not have that much memory but only crashes during runtime (static will not allow program to run at all bc if dh enough memory, will reject program execution)
  • may lead to memory fragmentation (avail memory on device no longer in large continuous blocks but in small fragments :. os may not be able to find large contiguous blocks of memory for static allocations when req)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly