Witscale Test Center

SCJP Objectives Covered


SCJP Objectives Covered

Section 3: Garbage Collection

 

3.1 State the behavior that is guaranteed by the garbage collection system.

 

3.2 Write code that explicitly makes objects eligible for garbage collection.

 

3.3 Recognize the point in a piece of source code at which an object becomes eligible for garbage collection.

 

 

 

While programming in Java you hardly worry about the actual physical memory allocated to your programs. Java does the memory management (for you) so you really need not worry about it. However, you can cause memory leaks due to bad programming despite the excellent memory management that Java provides. Moreover, you may never come to know about them if you are unfamiliar with Java’s memory management techniques. You may also falsely assume that since Java manages the memory you will never run out of it. Therefore it is important to know about the memory management in Java. We have already seen how the memory is allocated when you create an object (Chapter 1). This chapter discusses the technique of freeing the memory (garbage collection) after you are done with the object.

Specifically, this chapter covers the entire third SCJP objective (3.1, 3.2, 3.3 sections). For the exam, you need to know how garbage collection works, what behavior it can guarantee. To understand this chapter better, you need to know how Java object is created in memory and the basics of memory model of java that are discussed in Chapter 1.