Understand .NET memory management internal workings, pitfalls, and techniques in order to effectively avoid a wide range of performance and scalability problems in your software. Despite automatic memory management in .NET, there are many advantages to be found in understanding how .NET memory works and how you can best write software that interacts with it efficiently and effectively. Pro .NET Memory Management is your comprehensive guide to writing better software by understanding and working with memory management in .NET. Thoroughly vetted by the .NET Team at Microsoft, this book contains 25 valuable troubleshooting scenarios designed to help diagnose challenging memory problems. Readers will also benefit from a multitude of .NET memory management “rules” to live by that introduce methods for writing memory-aware code and the means for avoiding common, destructive pitfalls.
What You'll Learn Who This Book Is For
.NET developers, solution architects, and performance engineers
Konrad is programming for over a dozen years, solving performance problems and architectural puzzles in the .NET world, speeding up web applications. Working as independent software development consultant. He also shares his passion as a trainer at Bottega IT Solutions in the area of .NET, especialy about application performance and diagnostics. He also provides customized on-site trainings dedicated solely to .NET memory management topics.
Blogger, speaker and fan of Twitter. He loves .NET community - attending many conferences and even organizing some (like DotnetConf PL). Co-founder of https://dotnetos.org initiative of three .NET fans organizing tours and conferences about .NET performance. Founder of the Warsaw Web Performance group. Microsoft MVP in the Visual Studio and Development Tools category.
There are some technical books that show you how something works. And that's it. There's this other kind, which guides you through the woods, showing you breadcrumbs to follow. It allows you to think about the content and ideas presented, and reason what are the next steps. This book definitely belongs to the second kind.
It contains a lot of knowledge presented in a good format. Every chapter is supported by a summary and/or some scenarios where you can apply the already gained knowledge. When reading it, sometimes it was more like a workshop experience than just a book.
My favorite part, which again shows the reasoning that you might come up with on your own, just following the breadcrumbs, is related to gaps and plugs. It shows how memory, that is known to contain garbage, is reused to store additional data for GC plan. Again, it shows how to drive "the plot", to keep the reader interested and thinking at the same time.
The only disadvantage that I can mention is formatting and some minor errors (upper/lower case, etc.). For the formatting: fonts used in code snippets, regular text and block (quotations) are so different that sometimes it's hard to read one after another. This does not impact the content though, which is really heavy and awesome at the same time.
If you develop in .NET or you're about to start doing it, this is a must-read.
FYI: I know author personally, as we're part of Dotnetos initiative.
Nowadays, computers, smartphones and other electronic devices have more and more RAM available. Microsoft creating the .NET platform took care of providing mechanisms responsible for automatic memory management. This allows developers to focus on implementing business logic and quickly delivering applications to the market. Unfortunately, these aspects also reduce the importance of effective memory management in the software development process. Developers become unaware of what is happening with memory allocation of their programs. This, in turn, causes the process of continuous memory profiling to be skipped. It also tempts developers not to think about what is happening with memory allocation.
I was looking for a book about memory management in the .NET for a very long time. Unfortunately, most of them only deal with this topic in part. Author has filled the niche by creating a book fully devoted to memory management in .NET.
The book starts with non .NET basic concepts related to memory organization and computers architecture from a high-level perspective.
Chapter 2 shows memory management from the low-level perspective - both the hardware side as well as the software side (both for Windows and Linux operating systems).
Chapter 3 presents techniques for collecting information about memory consumption and their correct interpretation. Free and commercial tools were also presented.
The next three chapters were devoted to the organization and allocation of memory from the .NET perspective.
Chapters 7-10 provide a comprehensive description of the Garbage Collection process. Each of GC phases (Mark, Plan, Sweep & Compact) has its own dedicated chapter. For brevity's sake, all phases were explained based on the simplest GC mode: Non-Concurrent Workstation.
The next chapter consists of a detailed description of all available GC modes combinations (Workstation/Server, Concurrent/Non-Concurrent) and their pros and cons.
Chapter 12 is devoted to the lifetime of objects and techniques of their finalization. The subject of Weak References was also discussed.
The next two chapters contain a lot of advanced techniques mostly related to managed pointers and ref types. There is also a lot of information about proper usage of the newest types in the .NET world: Span and Memory. The chapter ends with the description of upcoming .NET features like pipelines and nullable reference types.
The book ends with the list of useful APIs and very interesting way of changing Garbage Collector implementation into the custom one.
What is great is that "Pro .NET Memory Management" is full of practical scenarios of detecting memory issues based on use cases of well-known applications (i.e. nopCommerce). It perfectly balances theory with practice. Furthermore, due to the complexity of that topic, the author put a lot of references to the .NET CLR source code where to dig deeper for very low-level details.
It is also worth mentioning that the book contains a description of the memory management process of the .NET Framework as well as the latest .NET Core (2.1).
I highly recommend this book to architects and more advanced .NET developers (especially who works on high-performance, low-latency projects). Konrad Kokosa in his book shows that sometimes only a small change in code can gain application's performance and make some parts of it even free of memory allocation. I really enjoyed the journey to the world of .NET memory management and I think that this book makes me better and more memory-aware .NET developer.
First of all, I know Konrad personally and that was the main reason I started reading this book. I was sure that I will read it by skipping a lot and probably don't learn a lot. I was WRONG! Totally WRONG! I even didn't finish it and already apply some knowledge to fix a problem. Will I solve it without the book? Yes, but this will take me probably longer, much longer.
I'm amazed how Konrad explains difficult concepts in simple worlds. And still, you can read it on the bus (on Kindle of course). It is must read position for dotnet developers.
I am currently still reading this book. The books contains so much awesome knowledge. My understanding of memory management grew with leaps compared to what I used to know.
+1 must read for every .NET developer.
Makes me more aware of the impact of the code I write.
The best book about .NET runtime that I have read. Konrad goes through the basic assumptions of each application, such as a pile or stack, and then slowly goes to the meat. The chapters are completed with great summaries and usage examples that can help you understand the topic.
It's very worth to read. I recommend to have clear mind and notebook next to you, because you are going to learn a lot!
Excellent book! Definitely a must-read for any .NET developer of any seniority. Book is full of very deep, technical knowledge about .NET internals and regardless of immense number of pages it's just so interesting I swallowed it whole in few days. Besides of the raw technical content it also provides many great tips of how we can improve performance and debug memory related issues of any .NET application.
Amazing amount of knowledge packed in quite a big book. Don't be afraid, it's well explained and helps with understanding what's going on underneath your application and how you can write more efficient applications! Thanks a lot Konrad for that masterpiece!
An extensive overview of Memory Management in .NET with common pitfalls and how to avoid them. Highly recommended for everyone interested in the (bottomless) depths of Memory Management.
Amazing book covering fascinating details about the .NET Runtime. Even if you write business applications where performance and memory efficiency is not a priority, this book is worth reading.
obviously a must read for anyone who is designing and writing low-latency and / or data intensive C# (mainly) code on top of .NET platform, i.e. would benefit from understanding how to work along and utilise intricate knowledge of GC internals; However, the book at over 1k isn't without page faults ;-) It's quite verbose (bit like reading a transcript of a really well prepared training) and has a tendency to go very deep into (crossing into implementation details) making it a tad hard for a reader to see the big picture (the rare comparison to JVM is helpful, but it would be really nice to see JS V8 (or other engine), Go, Rust, etc memory management models referenced to help understand which parts are .NET specific and which are generic concepts we should be aware of on other platforms), there are only 2 chapters dedicated to the subjects you will probably get biggest value from - I bet, the book will definitely trigger attempt to try Span, ref struct, align you struct fields, etc, but that's imho delivered as a cheery on the cake (rather than being the filler); finally I think I haven't seen enough on interoperability - after all optimising serialisation / deserialisation, P/Invoke or memory mapped files are things people who focus on low-latency spend quite some time on. Personally, I guess I might have learn a bit more from learning how to implement Zero GC (and comparison if it vs. standard GC) and would be quite happy to leave the historical divagations (and even .NET Framework) behind, but I get that's not what most readers would be interested in.. Overall, verbosity and the worst DTP I've seen in years (nothing that author could do about I guess) aside, the book delivers and it's exactly what it says on the tin and if you work on this level your time invested in it won't be wasted.