1 / 4

Local and Dynamic Storage

Local and Dynamic Storage. Bryce Boe 2012/09/04 CS32, Summer 2012 B. Overview. Project 2 Code Overview Local Variables Dynamic memory allocation. Local Variables. Local variables are stored as part of a function’s activation record on the stack void count_down ( int n) {

kera
Download Presentation

Local and Dynamic Storage

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. Local and Dynamic Storage Bryce Boe 2012/09/04 CS32, Summer 2012 B

  2. Overview • Project 2 Code Overview • Local Variables • Dynamic memory allocation

  3. Local Variables • Local variables are stored as part of a function’s activation record on the stack void count_down(int n) { cout << n << “ “; if (n > 0) count_down(n – 1); }

  4. Dynamic Variables • Stored in the heap • Allocated via malloc-family or new • Deallocated via free or delete • Process’s memory management (provided by libc) maintains free lists • Requests more memory from the OS as necessary • Requires a local or static variable to point to the allocated resource

More Related