Understanding Memory Performance Counters

[Update - September 30, 2010]

Since I studied a lot of this and related topics, I will write all the tips that I have gathered from my experience and the suggestions presented in the answers here -

1) Use a memory profiler (try the CLR Profiler to get started) and find routines that consume max mem and fine-tune them, such as reusing large arrays, try to maintain minimal object references.

2) If possible, allocate small objects (less than 85k for .NET 2.0) and use memory pools if you can avoid using a large amount of processor by the garbage collector.

3) If you increase links to objects, you are responsible for removing links to them as many times. You will have peace of mind and the code will probably work better.

4) If nothing works and you are still clueless, use the exception method (comment / skip code) to find out what consumes most of the memory.

Using memory performance counters inside your code can also help you.

Hope this help!


[Original question]

Hello!

I am working in C # and my problem has an exception in memory.

I read an excellent article on LOH here → http://www.simple-talk.com/dotnet/.net-framework/the-dangers-of-the-large-object-heap/

Amazing to read!

A, http://dotnetdebug.net/2005/06/30/perfmon-your-debugging-buddy/

My problem:

. ( WinDBG !), .

CLR . :

  • ,

, , CLR Profiler Performance Counters ( ), :

  • , - , ?!?!

  • - ?


:

:

  • (, ) (, , ), GC.Collect, . , 500 ( :-() .

  • , - ,.NET GC OOM.

  • , 85 LOH? ? .

  • , OOM?

,

  • - - . - string [] null, # Heaps !

  • / > 85 - . , LOH.

3.

Memory Leaks Indicators:

# bytes in all Heaps increasing
Gen 2 Heap Size increasing
# GC handles increasing
# of Pinned Objects increasing
# total committed Bytes increasing
# total reserved Bytes increasing
Large Object Heap increasing

:

  • 4- 32- Wink 2K3 SP2 .
  • , <= 2
  • ( ) .

OOM, , .

! , - !

+5
3

, .

  • , GC. , : .
  • - , . , :
    • LOH , Gen2, LOH . LOH .
    • 500Kb - (, API ), , . GC, .
    • 85K . , System.Array , 500K [] LOH.
    • , , , BIAH ( ) LOH . BIAH (Gen1 + Gen2 + LOH, , Gen0 - Gen0, ?:)), LOH - , [].

  • -, : .

  • , , , ( , IO): , . std:: deque STL STL. , 85K, LOH. , , : LOH , GC. [] ( ), Gen0 Gen1, GC, Gen2 .

  • : , GC, , . , - , , .

  • % Time GC counter, . , GC- "" . , , : , , % Time GC 20% .

, , , : , BIAH, Total commit bytes, LOH size, Gen0, Gen1, Gen2 size, # Gen0, Gen1, Gen2,% GC. .

+2

. , 500 . , , - , , , 10 , 5 .

:

  • . , . , .

  • , . , . , .

  • , .

, , , . , . ( ) , , gc.

+2

Private Bytes vs. Bytes in all Heaps. Private Bytes , Bytes in all Heaps, . " " , " ", .

, @Alexey Nedilko :

" LOH , Gen2 external , LOH . LOH .

. Gen2 , , . LOH ( ), , . , , , . , LOH, . OOM, , .

GC API ( .NET 4.51) , LOH, - . . , GC , . IMO, , - LOH, - - , . - - , , , , .

A good visual example of how this can happen is here Dangers of a large heap of objects and here An inaccessible heap of large objects is Maoni (GC team leader on the CLR)

0
source

All Articles