1 / 7

Run-Time Storage Organization

Run-Time Storage Organization. Introduction. We need to relate the static source text of a program to the actions that must occur at run time We need to allocate and manage the memory used by the program (static and dynamic). Memory Allocation Techniques. Static Allocation Stack Allocation

rhona
Télécharger la présentation

Run-Time Storage Organization

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Run-Time Storage Organization

  2. Introduction • We need to relate the static source text of a program to the actions that must occur at run time • We need to allocate and manage the memory used by the program (static and dynamic)

  3. Memory Allocation Techniques • Static Allocation • Stack Allocation • Heap Allocation Code Static Data Stack Heap

  4. Static Allocation • The number and size of all objects to be allocated is known at compile time • It is used for: • Global variables that are fixed in size and accessible throughout program execution • Program literals (constants) • Program code

  5. Stack Allocation • Information needed by a single execution of a routine (a procedure, function or method) is managed using an activation record or frame • An activation record contains local variables, parameters, return address, etc. • Activation records are pushed and popped as functions calls begin and end

  6. Parameter Passing • Call-by-value can be implemented as follows: • A formal parameter is treated like a local variable, so the storage for the formal is in the activation record of the called routine • The caller evaluates the actual parameters and places their values in the storage for the formals • Call-by-reference • The caller passes to the called procedure a reference to the storage address of each actual parameter

  7. Heap Allocation • The heap is used to store data which can be allocated and freed at any time and in any order • Deallocation is either manual or automatic (garbage collection) • The heap typically becomes fragmented during use

More Related