Next you can see how to log when garbage collections take place, and you can specify the size of the young generation.
- The next option is useful if you…want to monitor how often garbage…collection is taking place in your application.…We know that you can check this using the…Visual VM application,…but if you want a quicker way just…to monitor it, this might be useful.…The argument is -verbose:gc.…The verbose argument does have…some other options you can output,…but these aren't related to memory…or garbage collection so I'm not going to cover those here.…
You can read the Java docs if you're interested.…Just to see this one in action,…I've come up with some simple code.…You could pause the video and…type this in if you'd like.…It's not too exciting.…What I've got is an array of customers…and then a never ending loop…that adds a new customer to the array.…If the number of items in the array…is going to the one hundred,…then it removes 10 of the customers from the array.…So we'll be, every so often,…removing 10 items at a time.…
Those 10 items will then be…eligible for garbage collection.…I expect if we run this with a…reasonably small heap,…
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: Garbage collection and generation sizes