Despite the existence of Garbage Collection Java applications often suffer from memory problems - this course shows you how to solve them. In this course, Understanding and Solving Java Memory Problems, you'll learn how to solve problems relating to memory in Java. First, you'll explore how to solve the problem of memory leaks. Next, you'll discover advice about over-consuming your memory and running out of heap. Finally, you'll learn why your application can be too slow due to the effect of allocating memory at too fast of a rate. By the end of this course, you'll learn how to solve these problems and also how to understand memory related problems in general.
Course Overview Hi everyone, my name is Richard Warburton, and welcome to my course: Understanding and Solving Memory Problems. I'm an independent developer, consultant, author, and a recognized Java champion, mostly coding low latency and high performance applications. This course is going to help you solve problems related to memory in Java. That's really exciting because these are some of the most fun problems to diagnose and solve, and they can also lead to really bad production outages if you don't get them right. In this course, we're going to take a scientific approach: measuring what's wrong before we tackle problems. We'll be solving a variety of different problems, including: memory leaks, where your application constantly eats more and more RAM, over-consuming your memory, and running out of heap, and also seeing how your application can be too slow due to the effect of allocating memory at too fast a rate. By the end of this course, you'll know how to solve these problems and also how to understand memory-related problems in general through the use of memory profiling, heap dumps, and object histograms. Before beginning the course, you should be familiar with Basic Core Java SE, but that's really all you need to get going. I hope you'll join me on this journey to learn more about Java performance problems with the Understanding and Solving Memory Problems course, at Pluralsight.
Advanced Memory Leaks I'm glad you enjoyed the previous module. Welcome to Advanced Memory Leaks. In this module, you'll get to learn about certain techniques which can really help augment what we learned in the previous module. That isn't to say what we learned in the previous module isn't useful, it will cover most memory leaks that you're likely to encounter, but this module takes that knowledge a little bit further by covering situations where a slightly different approach is required. There are three main scenarios where that's the case. Firstly, there are ClassLoaders. Now ClassLoaders are a powerful feature of the JVM, but custom ClassLoaders can sometimes cause complicated memory leaks. We'll look at a scenario where it seems like there will be no reference to a class, but in practice it gets retained. Then you will learn about ThreadLocal variables. These are another useful feature of the JVM that can result in memory leaks if misused. ThreadLocal memory leaks can be detected in the same way as normal memory leaks, but require a slightly different solution. And finally, there is off-heap memory, which is to say memory that's being manually allocated in a separate space to normal Java memory. This has its own set of tricky issues.
Solving 'Out Of Memory' Errors This module is called Solving 'Out Of Memory' Errors, and the first thing we're going to talk about here is how do we know when we've actually run out of memory to begin with? And the answer is that you'll see this error message somewhere in your application: java. lang. OutOfMemoryError: java heap space. It might be printed on the command line, it might be in a log file somewhere if your application's logging things. It might be a thoroughable that's being recorded, and captured, and logged somewhere. What's worth noting is we'll only be looking at the Java heap space version of this problem. So when you've run out of heap space, rather than off-heap areas, such as Metaspace, as we talked about in the previous module, or off-heap buffers for network access or anything like that. And this module is designed to solve the problem that you've run out of memory, you've hit this error, or you've seen this error, but don't worry if you've not seen this error in production, it's really helpful to know a little bit ahead of time what to do when it happens. Now, there's three basic questions that we're going to answer in this module, and the first question is what causes out of memory errors, and there are two main causes that we'll look at. Now, we won't just describe the causes, we're going to give an example of tracking down solutions to this problem as well, and finally, we'll look at proactive solutions, reacting to problems is okay, but it's not ideal. Sometimes you can proactively prevent problems in this area.