VM Learning: Memory Management

Hi folks,

I started to work recently with a Master student on the memory management of the Pharo VM. She has worked previously on the VM profiler and she is now focusing on the incremental garbage collector.

In this context, I am trying to get her skills up to speed on Spur, the current Memory Manager. To do so, I wrote a simple exercise that might be of general interest, so I am going to share it here.

Note however that the exercise is designed similarly to French “khôlle”. A khôlle is an oral exam where the teacher asks a couple questions to the student and the student has one entire hour to answer the question during which he will use a blackboard to explain the rationale leading to his answer. The teacher evaluates both the result and the rationale behind the result. If the student answers in one sentence to the question, this means he did not understand something correctly (the answer cannot be this obvious).

Exercise: Understanding the memory representation of objects

Let’s say we have the following class:

Object subclass: #Person
  instanceVariableNames: 'name age height socialNumber siblings'
  classVariableNames: ''
  package: 'PeoplePackage'

and the following method:

Person class>>createJohnWithSibling1: sibling1 andSibling2: sibling2
^ Person basicNew
    name: 'John';
    age: 47;
    height: 1.83;
    socialNumber: 189345472112;
    siblings: {sibling1.sibling2};

The method createJohnWithSibling1:andSibling2: is executed with two other instances of Person as arguments. When the method was activated, there was enough room in Eden to allocate all the objects which required to be allocated during its execution. The whole method is executed in a single process, which is not interrupted (no external events, no process switch) during the entire execution of the method.

We note that the code is run in Pharo 6, on the Cog VM, with the Spur memory manager.

Question 1:
How many bytes were allocated in Eden during the execution of the method createJohnWithSibling1:andSibling2: in 32 bits and 64 bits ? Explain the theoretical value of each word/byte/bit allocated.

Question 2:
The method has now been fully executed. Draw the memory representation of the instance John returned by the method as well as all objects it refers to directly and through the class index (each of its instance variable and its class). Detail the difference between 32 bits and 64 bits representations. Explain the theoretical value of each word/byte/bit present in each of the objects represented.

This post is relevant to help:
Spur’s new object format

I am not going to provide a detailed solution for this exercise on the blog. However, if you found the solutions and you have some questions or you want to discuss with me about it, feel free to contact me by mail at clement (dat) bera (at) inria (dat) fr. Depending on my availability, I may answer you directly by mail or set-up a Discord or Skype meeting.

I hope you enjoyed the post.