Java Reference
In-Depth Information
Java's Approach to
Memory and Concurrency
This chapter is an introduction to the handling of concurrency (multithreading)
and memory in the Java platform. These topics are inherently intertwined, so it
makes sense to treat them together. We will cover:
• Introduction to Java's memory management
• The basic mark and sweep Garbage Collection (GC) algorithm
• How the HotSpot JVM optimizes GC according to the lifetime of the object
• Java's concurrency primitives
• Data visibility and mutability
y d
Basic Concepts of Java Memory Management
In Java, the memory occupied by an object is automatically reclaimed when the
object is no longer needed. This is done through a process known as garbage collec‐
tion (or automatic memory management). Garbage collection is a technique that
has been around for years in languages such as Lisp. It takes some getting used to
for programmers accustomed to languages such as C and C++, in which you must
call the free() function or the delete operator to reclaim memory.
Search WWH ::

Custom Search