Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
43 Cards in this Set
- Front
- Back
Activation Record
|
Block of memory that stores the activation-specific data of a function.
-Return address, local variables, caller's activation record |
|
Static Activation Record Allocation
|
-Efficient, simple
-Allocates record for each function before running -Drawback: Can only run one instance (activation) at a time -Recursion would overwrite data |
|
Dynamic Activation
|
-Each instance has its own record
-Records pushed onto stack so function knows where to look (since dynamic, doesn't know where the instances will be) |
|
Nested Function Handling
|
Uses a nesting link to store most recent activation of the calling function.
|
|
Block Activation Records
|
-Blocks inside functions (if,else,for,etc)
-could pre-allocated -could extend the parent function's activation record -could create own separate activation record |
|
Nesting Link
|
Used to keep track of calling function by inner functions
- If calling top level, set to null -If calling nested function from top level, set to caller's activation record - If calling nested from nested, set to nested's nested link |
|
Function as Parameter
|
Function will pass nested link of parametered functions activation record
|
|
Long Lived Activation Records
|
If activation record still has a link from some active function, cannot be deallocated from the stack. This allows the record to be called from later functions.
|
|
Memory Stack Allocation
|
-Uses One more word than requested
-Last word stores the previous top location so can return when deallocated |
|
Memory Heap
|
A pool of blocks of memory with an interface for unordered allocation and deallocation
|
|
First-Fit (Heap)
|
-heap manager maintains linked list of free blocks
-For allocate, manager searches list for first block big enough for request -To deallocate, returns block to front of list -end of list denoted by -1 value |
|
Coalescing
|
After deallocating from a heap, checks if adjacent blocks are also free and, if so, merges
|
|
Quick Lists (Heap)
|
-One list of free blocks are all small and same size (more popular). Use delayed coalescing.
-Other list of larger blocks, treated normally |
|
Delayed Coalescing (Heap)
|
In a Quick List, deallocated blocks are not immediately coalesced. Only after certain threshold.
|
|
Fragmentation
|
Many disjointed allocated and unallocated blocks
|
|
Heap Mechanisms
|
Placement - Where to allocate blocks
Splitting - How to split up larger blocks Coalescing - When and how to recombine |
|
Placement (Heap)
|
First Fit
Best Fit Next Fit Can use balanced binary tree |
|
Splitting (Heap)
|
Split to requested size
Split to bigger size Round up to given multiple |
|
Coalescing (Heap)
|
No coalescing - never
Eager coalescing - ASAP Delayed coalescing - after run out of space |
|
Current Heap Links
|
A memory location where a value is stored that the running program will use as a heap address
|
|
Tracing current heap links
|
-Start with root set (all memory locations, static variables, activation records that haven't returned. Not variables that cannot b used as heap address (ie int)
-do this for each memory location |
|
Errors in current heap links
|
-Exclusion errors: mem location that is a current heap link, but left out
-Unused inclusion errors: mem location included, but never used by the program -Used inclusion errors: mem location is included, but not used as a heap address |
|
Heap Compaction
|
Defragment the heap
|
|
Garbage Collection
|
Automatically reclaims deallocated blocks
3 types -Mark and sweep -copying -reference counting |
|
Mark and Sweep
|
2 stage process
-Mark all live heap links and mark heap blocks linked to them -Sweep through and return unmarked blocks to the pool -Heap remains fragmented -Resistant to both Inclusion Errors |
|
Copying Collection
|
-Divides memory in half and uses one half at a time
-When one half becomes full, copies all live blocks to other half, compacting as it goes -Deletes first half -Sensitive to Used Inclusion Errors |
|
Reference Counting
|
-Each block has a counter of heap links to it
-Increment when heap link is copied, decrement when discarded -when count = 0, block is garbage and is released -Does not use current heap links -poor performance, cannot collect cycles |
|
Garbage Collecting Refinements
|
-Generational: divide blocks according to age & collect younger blocks more often
-Incremental: Collect a little at a time |
|
Formal Parameter
|
In the method definition, the parameter given that will exist in the body of the method
|
|
Actual Parameter
|
In the program, the parameter that is passed to the function or method.
|
|
Positional Parameters
|
How languages match up parameters. nth formal parameter matched with nth actual parameter
|
|
Keyword Parameters
|
Matches actual parameters to keywords of the function
ex) (DIVIDEND => x, DIVISOR => y) |
|
Optional Parameters
|
Given default values if left blank
Good for shorthand of overloaded functions |
|
Unlimited Parameter Lists
|
keyword ... indicates a variable amount of parameters
|
|
Pass By Value
|
Java
-formal parameter is just like a local variable in the activation record of the calling method, but it is initialized with the actual value of the actual parameter -Actual value is not affected by method |
|
Pass By Result
|
-Formal parameter starts uninitialized
-After method is run, final value of formal is assigned to actual |
|
Pass By Value-Result
|
-formal is initialized with the value of the actual
-After method is run, final value of formal is assigned to actual -1st half of Value, 2nd half of Result |
|
Pass By Reference
|
-formal parameter is an alias for the actual parameter
-points to same memory location |
|
Pass By Macro Expansion
|
-Define the macro
-Basic textual substitution |
|
Preprocessing
|
-Replaces all macros with the code, replacing formals with actuals
-Each parameter is re-evaluated every time it is used |
|
Capture
|
When a macro has a parameter passed to it that is the same name as a variable in the macro
|
|
By Name
|
Each actual is evaluated in the caller's context on every use of the formal parameter.
-Both lvalue and rvalue. |
|
By Need
|
-like By Name, but only the first time
-after first assignment, used as local variable |