I had read that LinkedIn Learning was an acquisition and rebranding of the famous Lynda.com platform, but hadn't given it a try (nor have I taken any Lynda course in the past). But yesterday I saw that I had "free access" to some courses, and one of them looked interesting. Being an opportunity to a) see how the learning platform works and b) actually learn or at least refresh some Java concepts, I gave it a go.
On with the small review:
Java Memory Management It's a 3h course, roughly half of it code examples and exercise walkthroughs. We'll learn how Java keeps variables in memory, from basic stack-heap concepts to the final
keyword or String
specifics, basic JVM optimizations we can apply and, most important, an introduction to finding and debugging memory leaks and memory usage potential problems. I liked the introduction to a few tools, attaching to running applications and checking how memory grows (or keeps steady on well behaving programs) but also how to grab and afterwards load heap dumps.
Explanations are clear, diagrams simple and abundant, code examples to the point and easy to follow, and in general my only complaint is that the course is old, as mentions Java 8 being "recently released", which in 2021 is not the case anymore 🤓 Still, worth watching.
Notes
- primitives and object references go to the stack, objects to the heap
- one stack per thread
- one heap per application (shared between stack)
- object references are passed by value when passing objects as method parameters
final
does not apply const correctness- Easy to have escaping references, so return immutable objects (e.g.
unmodifiableMap
orImmutableMap
) and build readonly versions of objects - JVMs optimize and create objects in the stack if detects they are local scoped only
- Java does string interning, that's why it's important to use
.equals()
instead of==
when comparing them PermGen
heap existed until JDK7, Since JDK8 isMetaSpace
- Java VisualVM tool and the Visual GC plugin for memory analysis
- Memory Analyzer (MAT) (from eclipse.org) tool for heap dumps
Tags: Reviews