CS 123 - Java memory Model

Here is an illustration of the memory map for the following DrJava Interaction Pane session, which makes use of the Java class SimpleClassWithStaticAndInstanceState. This picture shows what Java's memory would look like at the end of the execution of these lines of code.

   > SimpleClassWithStaticAndInstanceState.increaseClassState()

   > SimpleClassWithStaticAndInstanceState obj1
   > SimpleClassWithStaticAndInstanceState obj2

   > obj1 = new SimpleClassWithStaticAndInstanceState()
   > obj2 = new SimpleClassWithStaticAndInstanceState()

   > obj1.increaseState()
   > obj1.increaseState()
   > obj1.increaseState()
   > obj1.increaseClassState()
   > obj1.increaseClassState()
   > obj2.increaseState()
   > obj2.increaseState()
   > obj2.increaseClassState()


Return to the CS 123 lecture page.


compliments and criticisms