Set Maximum Memory Usage C#

后端 未结 2 1314
忘了有多久
忘了有多久 2020-12-21 04:44

I have an application that must use a library that I didn\'t write and I don\'t have the power to change it. Basically there is a memory leak, so the long it runs, the more

2条回答
  •  醉话见心
    2020-12-21 05:30

    That is a per-process limitation in Windows. Each process gets ~2GB virtual address space (that is what Heap makes use of) in a 32-bit machine. And I am afraid there is not much you can do about it.

    Roughly, CLR is able hold upto ~1.6GB of objects in memory. That should be enough for most of the applications. If not, then you need to work on your application.

    In my case, I faced a similar problem and then used SqlDataReader to fetch objects in a specified chunk size, process it, compute it, clean it from memory, and then fetch another chunk.

    There is also a detailed article on MSDN - Investigating Memory Issues

    Hope this would be helpful.

提交回复
热议问题