Allowing iteration without generating any garbage

前端 未结 7 1219
时光取名叫无心
时光取名叫无心 2021-02-01 04:49

I have the following code in an object pool that implements the IEnumerable interface.

public IEnumerable ActiveNodes
{
    get
    {
        for (int i         


        
7条回答
  •  旧时难觅i
    2021-02-01 05:09

    Also, you can have a pool of preallocated enumerators. Think about how many simultaneous enumerations you want to support.

    The garbage collection overhead will go, at the expense of extra memory consumption. Speed vs. memory optimization dilemma in its purest form.

提交回复
热议问题