Major Update on 10th April 2009, inclusion of C++ programming language!
Updated on 18th April 2008, a complete example on stack and heap
Updated on 15th April 2008, new contents and new layout!
Updated on 6th April 2008, new contents!
The paper you can download from here is about a model for memory management during the execution of programs written in Java and C++.
It started on March, 2008 as a summary of the lecture notes of both the “Programming Project” and
“Software Engineering Project” courses held by professors of the CASE (Center for Applied Software Engineering) of the Free University of Bolzano – Bozen.
The first versions of this publication were only about Java memory management.
Subsequent revisions added information found on other sources. Unfortunately, the author forgot to
reference the sources on the document.
On March, 2009 the author began to add the information about C++ programming language. More
information from other sources were added, including their attribution.
The biggest source of this document is still the set of presentations of CASE.
The code snippets and their corresponding stack/heap diagrams are copied in full from those of the
The next major revision will contain original images (not belonging to CASE slides), as well as other code
snippets that I could find more clear than those of CASE.
If you find that this document contains information taken from one of your publications, please
contact the author, that is willing to either delete them from this document or to add an attribution to
Table of Contents:
- The model
- Code load and execution
- Activation Record (AR)
- Contents of the Activation Record
- Abbreviations for
- Declaration vs. Definition
- The scope of a variable
- Extent of a Variable
- Scope Activation Record (SAR)
- Example on SAR
- Role of SLs
- Dynamic Memory Allocation And Handling
- Dynamic Vs. Static memory allocation
- Dynamic Memory Scope and Extent
- Accessing dynamic memory
- Object instantiation
- Objects in Memory (Java)
- Objects in Memory (C++)
- Memory Management issues (Java)
- Memory Management issues (C++)
- Methods (Java)
- Methods (C++)
- The null value (Java)
- The NULL value (C++)
- Parameter Passing (Java)
- Example of parameters passing (Java)
- Example of parameters passing (Java), continued
- Parameter Passing (C++)
- Example of parameters passing by value (C++)
- Example of parameters passing by reference (C++)
- Pointers vs. Parameters (C++)
- Previous example using pointers (C++)
- Inline initialization
- A constructor’s call (Java)
- Class attributes
- Example of class attributes (Jav)
- Example of class attributes (C++)
- Class Method
- Example of Stack/Heap Diagrams in Java
- Stack Diagram
- Heap Diagram
- Memory portions assigned to a program (code area, heap / dynamic memory area), execution stack
- How code is loaded in Java
- The Activation Record (AR) and function calls
- Abbrevations (AR, RV, RA, SP, N/E, @, ??, arb)
- Examples on method calls and activation records usage
- Declaraion vs. Definition of a variable, the scope of a variable, blocks
- Scope Activation Record (SAR), Static Link (SL), the role of SL
- The extent/lifetime of a variable
- Dynamic memory allocation and handling
- Dynamic vs. Static memory allocation
- Dynamic memory scope and extent
- Accessing dynamic memory
- Classes and Objects in detail, object instantiation
- Memory Management issues
- Objects vs. Variables (definitions)
- Methods of Objects
- Class Attributes
- The null value
- Parameters (formal, actual), parameters passing (by reference, by value)
- Constructors and Inline Initialization
- Constructor’s call
- Class attributes (static variables)
- Class methods (static methods)
- Complete Example of Stack/Heap Diagrams
Everything is integrated with simple examples.