{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lec8 - Lecture 8 Dynamic Memory Allocation CS240 1...

Info icon This preview shows pages 1–19. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture 8 Dynamic Memory Allocation CS240 1 Wednesday, February 9, 2011
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Memory Computer programs manipulate an abstraction of the computer’s memory subsystem Wednesday, February 9, 2011
Image of page 2
Memory: on the hardware side 3 @ http://computer.howstuffworks.com/computer-memory.htm/printable Wednesday, February 9, 2011
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Memory: on the software side 4 Each computer programming languages offers a different abstraction The goal is to make programming easier and improve portability of the source code by hiding irrelevant hardware oddities Each language offers a memory API -- a set of operations for manipulating memory Sample exam question: - How does the abstraction of memory exposed by the Java programming language differ from that of the C programming language? Wednesday, February 9, 2011
Image of page 4
Memory: the Java Story Memory is a set of objects with fields, methods and a class + local variables of a method Memory is read by accessing a field or local variable Memory is modified by writing to a field or local variable Location and size of data are not exposed Memory allocation is done by call in new Question: - Does main() terminate? 5 while ( true ) { c1 = new Cell(); c1. next = c2; c2 = c1; } class Cell { Cell next ; } Wednesday, February 9, 2011
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Memory: the Java Story Question: - Does main() terminate? 6 while ( true ) { c1 = new Cell(); c1. next = c2; c2 = c1; } Wednesday, February 9, 2011
Image of page 6
Memory: the Java Story The semantics of new is as follows: Allocate space for the object’s fields and metadata fields Initialize the metadata fields Set all fields to null/zero/false Invoke the user defined constructor method 7 Heap next fields metadata hash lock class + methods Wednesday, February 9, 2011
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Aparté Garbage collection is the technology that gives the illusion of infinite resources Garbage collection or GC is implemented by the programming language with the help of the compiler Though for a some well-behaved C programs it is possible to link a special library that provides most of the benefits of GC Question: - How does GC work? 8 Wednesday, February 9, 2011
Image of page 8
Garbage Collection thread#2 thread#1 heap Phases Mutation Wednesday, February 9, 2011
Image of page 9

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Garbage Collection thread#2 thread#1 heap Phases Mutation Wednesday, February 9, 2011
Image of page 10
Garbage Collection thread#2 thread#1 heap Phases Mutation Wednesday, February 9, 2011
Image of page 11

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Garbage Collection thread#2 thread#1 heap Phases Mutation Stop-the-world Wednesday, February 9, 2011
Image of page 12
Garbage Collection thread#2 thread#1 heap Phases Mutation Stop-the-world Wednesday, February 9, 2011
Image of page 13

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Garbage Collection thread#2 thread#1 heap Phases Mutation Stop-the-world Wednesday, February 9, 2011
Image of page 14
Garbage Collection thread#2 thread#1 heap Phases Mutation Stop-the-world Root scanning Wednesday, February 9, 2011
Image of page 15

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Garbage Collection thread#2 thread#1 heap Phases Mutation Stop-the-world Root scanning Wednesday, February 9, 2011
Image of page 16
Garbage Collection thread#2 thread#1 heap Phases Mutation Stop-the-world Root scanning Marking Wednesday, February 9, 2011
Image of page 17

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Garbage Collection thread#2 thread#1 heap Phases Mutation Stop-the-world Root scanning Marking Wednesday, February 9, 2011
Image of page 18
Image of page 19
This is the end of the preview. Sign up to access the rest of the document.
  • Spring '08
  • REGO
  • Garbage collection, Marking Sweeping Compaction, Phases Mutation Stop-the-world, Mutation Stop-the-world Root

{[ snackBarMessage ]}