dynamic storage Flashcards

1
Q

dynamic storage allocation

A

run-time allocation of storage for variables, structures, procedure calls
most lang, total amount storage cannot be determined at compile time (except fortran)

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

language features that require dynamic storage

A
  • recursion
  • pointers, explicit allocation
  • dynamic data structs( list/dynamic arrays, trees, graphs)
  • hof (lambda)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

heap space via free-list

A
  • available blocks of storage chained together in linkedlist
  • when block is needed, removed from FL
  • when block is reclaimed, insert into FL
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

disadvantage free list

A
  • must search for block of right size
  • fragmented memory
  • expensive allocation, cheap reclamation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

heap pointer method

A
  • maintain available space as contiguous block of byes
  • similar to stack pter, points to next available byte
  • when object allocated, HP bumped by object size
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

disadvantages heap pointer

A
  • requires compaction of live objects (pushing togeher)

- cheap allocation, expsensive reclamation

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

gc task

A
  • find block of storage for dead objects

- make storage available for use

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

gc types

A
    1. mark/sweep: det set of all LIVe objects

2. ref count - during execution determine when object dies

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

mark/sweep live objects

A
  • live means: pointer exists for x in activation record; register exists for x; object y in heap containing pointer to x and y is alive
  • live objects found by graph traversal; start at root (local var on stack, global var, and registers)
  • any object not reachable by root is dead
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

mark/sweep gc

A
  • each obj has mark bit
  • heap filled, program suspended, gc starts
  • traversal (mark phase). sweep for those not marked.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

mark/sweep disadvantage

A
  • non compacting; use free list
  • expensive allocation
  • program suspension (stop and collect)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

copying gc

A
  • two heaps (FROM and TO)
  • obj allocated in FROM. when from fills up, gc starts
  • traversal copies FROM to TO live objects
  • space FROM vs TO flipped
  • use heap pointer (use forwarding address) in old object
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

fwding address vs ordinary pointer

A

fwding address is an address in TO space. no ordinary pter can point from FROM space into TO space

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

disadvantage cc gc

A
  • stop and copy

- heap half size, can occur twice freq (but space can be swapped to disk)

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

ref counting

A
  • ref count
  • increment when copied
  • decrement when object ref distroyed
  • obj space reclaimed at rc = 0
  • free list
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

ref counting advantage

A
  • storage reclaimation incremental

- not as long interruption

17
Q

ref counting disadvatage

A
  • cycles (use backup m/s)
  • hard to implement
  • evey object have ref count; possible overflow
18
Q

compact m/s gc advan

A
  • fast allocation use HP

- larger heap

19
Q

generational gc

A
  • older object lives longer
  • temp values live short
  • global ilve long thus
  • many heaps (with age)
  • younger heap are gc more often
  • when older gc filels up, then that gc will be collected
20
Q

m/s vs rc gc

A

m/s can collect cyclical structures

21
Q

cc gc vs m/s

A

cc is compact (use simple heap). cost of cc is proportional to size of live object. m/s/ proportional to size of heap.

22
Q

private type in ada

A

a type whose only operations are assignemnt (:=) and equality (=); users dont know about how it is implemented