Memory management module updated

I have made significant updates to our memory management and garbage collection training module. Previously, I left out the details of the memory manager in the OS and some of the hardware details of the UMA platforms. I also skipped the low-level details of the JVM and covered just strong, weak, soft and phantom references.

With the new version of the module, the first attendees are going to explore how deep the rabbit hole really goes! I talk about the various types of memory in a computer, then show how the operating system presents this memory to user processes (see Figure 1).
Low-level memory overview
I then take a plunge into memory management in user processes. I start with the simplest memory management strategy: reference counting. Even though it is not applicable to Java and [safe] .NET code, it is still widely used strategy.
Once the reference counting is out of the way, I look at true managed environments. I explore the operation as well as management of the managed heap. The example slide in Figure 2 shows what the JVM does to allocate an object on the heap.
Managed heap
Next, I show what happens when the JVM frees some objects and I don’t skim on the details. You will learn about the defragmentation strategies and you will understand exactly why generational heaps are an excellent idea (see Figure 3).
Heap compacting
But that’s not all. Lifecycle of Java objects is not simply active -> freed; Java objects can be finalizable, in which case, the garbage objects fester around until the finalizer thread deals with them. (Does ‘festering’ sufficiently convey the fact that finalizers are generally not a good idea? Yes? Good!)

Obviously, I did not remove the content on the reference types and their operation and typical usage. So, after taking this module, you will have a good understanding of what the OS and the JVM does to manage memory. You will also be able to use this knowledge to make your Java programs perform much better by configuring the garbage collector and using the appropriate references in your code.

A word of warning, though: this module is complex and you may be wishing that you did not sleep through those hardware architecture and discrete mathematics lectures!

This entry was posted in Jan's Blog and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>