This is a mirror of official site: http://jasper-net.blogspot.com/

Investigating Memory Issues

| Sunday, December 11, 2011
Contents
Tools of the Trade
GC Performance Counters
Windows Performance Counters
Verifying an OOM Exception in a Managed Process
Determining What Caused an OOM Exception
Measure Managed Heap Size
What If Objects Survive?
Is Fragmentation a Problem on Your Managed Heap?
Measuring Time Spent on Garbage Collection
Investigating High CPU Usage

Uncovering and correcting memory issues in managed applications can be difficult. Memory issues manifest themselves in different ways. For example, you may observe your application's memory usage growing unboundedly, eventually resulting in an Out Of Memory (OOM) exception. (Your application may even throw out-of-memory exceptions when there is plenty of physical memory available.) But any one of the following may indicate a possible memory issue:

    An OutOfMemoryException is thrown.
    The process is using too much memory for no obvious reason that you can determine.
    It appears that garbage collection is not cleaning up objects fast enough.
    The managed heap is overly fragmented.
    The application is excessively using the CPU.

This column discusses the investigation process and shows you how to collect the data you need to determine what types of memory issues you are dealing with in your applications. This column does not cover how to actually fix problems you find, but it does give some good insights as to where to start.
We'll begin with an overview of the most useful performance counters that can be used to investigate managed memory issues. Then we'll cover the tools that are commonly used for the investigation and will continue with a list of common managed memory issues and how to investigate them.
But before we get started, you should familiarize yourself with some fundamental concepts:

    Garbage collection in the Microsoft® .NET Framework. For more information, see these two blog entries: blogs.msdn.com/156626.aspx and blogs.msdn.com/234273.aspx.
    How virtual memory works in Windows®. This includes the concepts of reserving memory and committing memory.
    Using the Windows Debuggers (WinDbg and CDB).


Tools of the Trade
Before we start, we should spend a moment discussing some tools you will typically use to diagnose memory-related issues.

Read more: MSDN Magazine
QR: cc163528.aspx

Posted via email from Jasper-net

0 comments: