The JVM makes the mark and sweep process very efficient by using generations for the objects. See this in practice using the VisualVM tool.
- [Instructor] So this is the basic process…that modern garbage collectors follow,…but it's not the full story.…The problem with what we have just seen…is that if there are lots of objects…which are not garbage, then because…garbage collection is a stop the world event,…our application is paused while…the garbage collection process runs,…then the users of our application…will probably notice that our application has frozen,…perhaps for a few seconds at a time.…This wouldn't be acceptable, so…to avoid this, we have something called…generational garbage collection.…
The starting point for understanding…generational garbage collection…is that most objects in Java live…for a very short period of time.…If an object survives one garbage collection,…then its more likely to live forever.…We need to remember, it's faster…to collect when there's a lot of garbage,…when there are fewer objects that are surviving.…So generational garbage collection…is a way of organizing the heap.…The heap is divided into two sections.…
One is called the young generation…
Author
Released
12/19/2018- How memory works in Java
- Passing variables by value
- How objects are passed
- What are escaping references?
- How to avoid escaping references with collections and custom objects
- Garbage collection and generation sizes
- Detecting soft leaks
- Choosing a garbage collector
- Tuning a virtual machine
- Fixing a memory leak
Skill Level Intermediate
Duration
Views
Related Courses
-
Windows Performance Toolkit: Detecting Memory Leaks
with Thomas Pantels53m 32s Intermediate -
Learning Java Threads
with Peggy Fisher1h 9m Advanced
-
Introduction
-
Introduction1m 45s
-
-
1. How Memory Works in Java
-
Why memory is important1m 3s
-
The role of the stack5m 11s
-
The role of the Heap9m 36s
-
-
2. Values and References
-
Passing variables by value5m 26s
-
How objects are passed3m 30s
-
The final keyword6m 14s
-
Memory exercise1m 15s
-
Exercise walkthrough7m 18s
-
-
3. Escaping References
-
Exercise walkthrough10m 54s
-
4. Introduction to Garbage Collection
-
String pools9m 14s
-
Garbage eligibility5m 43s
-
-
5. Generational Garbage Collection
-
Mark and sweep2m 37s
-
-
6. Tuning the Virtual Machine
-
Heap size5m 16s
-
PermGen size1m 12s
-
Choosing a garbage collector4m 51s
-
-
7. Hunting for a Memory Leak
-
Monitoring the application8m 47s
-
Fixing a memory leak10m 39s
-
Conclusion
-
Course summary22s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Generational garbage collection