1

世代別ガベージ コレクションによってパフォーマンスが向上することは理解しています。

  1. Gen2 以外のコレクションでは、すべてのオブジェクトを最大 2 回移動する必要があり、Gen2 コレクションはまれです。
  2. システムが Gen0 コレクションを実行していて、オブジェクト (Gen1 または Gen2) が最後の Gen0 コレクション以降に書き込まれていない場合、システムはそのオブジェクトをスキャンしてその中の参照にタグを付ける必要はありません (それらはすべて Gen1 であるため)。または Gen2)。同様に、システムが Gen1 コレクションを実行している場合、最後の Gen1 コレクション以降に書き込まれなかったオブジェクトは無視できます。ガベージ コレクションの作業のほとんどはオブジェクトのスキャンであるため、スキャン時間の短縮は大きなメリットです。

Gen1 ガベージ コレクションから大きなオブジェクトを除外すると、どのようなパフォーマンス上の利点があるのでしょうか? 大きなオブジェクトは、ガベージ コレクターによってスキャンされても再配置されません。Gen1 コレクションは、オブジェクトの書き込みを介在させずに 2 つの連続する Gen1 コレクションが発生しない限り、または発生するまで、そのコンテンツをスキャンする必要があると予想されます。

私が見ていないパフォーマンス上の利点はありますか?

4

1 に答える 1

0

I'm curious, though, what performance advantage there could be to omitting large objects from Gen1 garbage collection?

There are two things -

First, large objects (large enough to be on the LOH) tend to have longer lifetimes. Short-lived large objects are rare, and in the cases where that's needed, you can typically reuse them. By not scanning, you're effectively avoiding scans that, nearly always, will result in keeping the objects anyways. This tends to give you a win in perf.

Also, in order to effectively treat objects in Gen1, and get many of the advantages provided by having a Gen1, they'd need to be able to compact. A large advantage of the generational collector is you're compacting the newest allocations, which tends to help keep the memory pressure lower as fragmentation tends to be better behaved. Large objects in Gen1 would cause performance or memory issues, as they'd either require compacting (right now, large objects are not compacted, since it's expensive to "move" them) or they'd cause extra fragmentation to creep up.

于 2011-06-24T17:17:55.787 に答える