Out of memory when creating a lot of objects C#

前端 未结 5 1836
醉梦人生
醉梦人生 2020-12-18 21:26

I\'m processing 1 million records in my application, which I retrieve from a MySQL database. To do so I\'m using Linq to get the records and use .Skip() and .Take() to proce

5条回答
  •  长情又很酷
    2020-12-18 21:32

    Well yeah.

    So at the end of that loop you'll attempt to have 2 million items in your list, no? Seems to me that the answer is trivial: Store less items or get more memory.

    -- Edit:

    It's possible I've read it wrong, I'd probably need to compile and test it, but I can't do that now. I'll leave this here, but I could be wrong, I haven't reviewed it carefully enough to be definitive, nevertheless the answer may prove useful, or not. (Judging by the downvote, I guess not :P)

提交回复
热议问题