开发者

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

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 &开发者_高级运维lt; 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).


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜