Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does dotTrace Performance Profiler mean by [Garbage collection]?

What does [Garbage collection] mean in this pic? And the "20 calls" thing?

I mean, how can I figure out why GC took so long? Was it collecting a lot of small objects? A single big one? Any hints as to how to optimize this at all?

The code in question is:

private void DeserializeFrom(SerializationInfo info)
{
    Width = info.GetInt32("width");
    Height = info.GetInt32("height");
    var data = (List<byte>)info.GetValue("cells", typeof(List<byte>));
    cells = new Cell[physicalSize.Width, physicalSize.Height];
    int pos = 0;
    for (int x = 0; x < physicalSize.Width; x++)
    {
        for (int y = 0; y < physicalSize.Height; y++)
        {
            cells[x, y] = new Cell();
            if (x < Width && y < Height)
            {
                cells[x, y].HasCar = data[pos];
                pos++;
            }
        }
    }
}

Nothing too fancy. I suspect the culprit is the big List<byte> object, but I thought collecting a single, big object is supposed to be instant (as opposed to collecting a bunch of small objects).

like image 243
Stefan Monov Avatar asked Sep 01 '10 13:09

Stefan Monov


People also ask

What is garbage collection in performance testing?

Garbage collection is the memory management process for objects in the heap. As objects are allocated to the heap, they run through a few collection phases – usually rather quickly as the majority of objects in the heap have short lifespans.

What is garbage collection in Dynatrace?

Java Memory Management, with its built-in garbage collection, is one of the language's finest achievements. It allows developers to create new objects without worrying explicitly about memory allocation and deallocation, because the garbage collector automatically reclaims memory for reuse.

What is garbage collection explain?

Garbage collection (GC) is a memory recovery feature built into programming languages such as C# and Java. A GC-enabled programming language includes one or more garbage collectors (GC engines) that automatically free up memory space that has been allocated to objects no longer needed by the program.

How does garbage collection affect performance?

An application that spends 1% of its execution time on garbage collection will loose more than 20% throughput on a 32-processor system. If we increase the GC time to 2%, the overall throughput will drop by another 20%. Such is the impact of suspending 32 executing threads simultaneously!


2 Answers

If you want to find out what is causing GCs, what objects are being allocated and collected, you can do it via dotMemory. Here is a tutorial that explains how to optimize memory traffic: https://confluence.jetbrains.com/display/NETCOM/Tutorial+3+-+How+to+Optimize+Memory+Traffic+with+dotMemory

like image 200
Maria Avatar answered Sep 19 '22 11:09

Maria


A little late to the party but if you are using .Net then you are using managed code, which basically means that the .Net runtime disposes your objects accordingly so you don't have memory leaks as opposed to C or C++.

Garbage Collection is whenever the runtime takes a time to manage the allocation and release of memory for the application. In this case that is what's taking place.

Please take a look at this filter that can be used with doTrace (I have version 6) so that you can analyze garbage collection and determine when it might be blocking your execution. https://www.jetbrains.com/profiler/help/CLR_Activity.html

like image 36
xmorera Avatar answered Sep 20 '22 11:09

xmorera