Programming Languages and Compilers

 

Lecture 11

 

In this lecture we look a bit further at run-time organisation, especially garbage collection.

 

The slides for this lecture can be found here.

 

Literature

 

Sebesta 6.9, Watt & Brown 6.6 and the article: “Uniprocessor Garbage Collection Techniques”, by Paul R. Wilson. Follow this link to download a copy or this link for a local copy.

 

As background reading I can recommend the website www.memorymanagement.org, especially the beginner’s guide.

 

You may also enjoy reading about memory management in C# and on .Net in general, see the article Memory Management in .NET

 

You may also enjoy a visualisation of how garbage collection works on the website Heap of Fish Java Applet - an Interactive Illustration of Garbage Collection

 

Exercises

 

Exercises for lecture 11 will be done from 12.30 till 14.15 before Lecture 12 on Tuesday the 13th of April.

 

The following exercises are best done as group discussions:

 

  1. Sebesta review questions 22, 23, 24, 27 page 287
  2. Sebesta problem set 12, 13, 14, 16 page 288 (in 12 and 13 discuss rather than write)
  3. Compare the mark&sweep GC algorithm to the generational GC algorithm. What are the pros and cons of each algorithm?
  4. Most Pascal implementations use a single memory block to implement both the stack and the heap allowing them to grow from each end. Suppose the stack and the heap meets because the free space is used up entirely. Discuss the options available to the implementor if the next allocation is from the stack and if the next allocation is from the heap.
  5. In parallel processing systems reference counting is often preferred to mark&sweep GC. Discuss why? Which GC algorithms may be more suitable than reference counting?

 

You should limit the discussion to about 5 minutes per question.

 

The following exercises you may prefer to do on your own or in pairs and discuss the outcome with your group:

 

  1. Watt and Brown exercise 6.21 page 246-247.
  2. Watt and Brown exercise 6.22 and 6.23 page 247.