Large Object Heap and String Objects coming from a queue

后端 未结 4 810
终归单人心
终归单人心 2021-02-14 01:06

I have a windows console app that is supposed to run without restarts for days and months. The app retrieves \"work\" from an MSMQ and process it. There are 30 threads that proc

4条回答
  •  旧巷少年郎
    2021-02-14 01:32

    Perhaps you could create a pool of string objects which you can use whilst processing the work then return back once you've finished.

    Once a large object has been created in the LOH, it can't be removed (AFAIK), so if you can't avoid creating these objects then the best plan is to reuse them.

    If you can change the protocol at both ends, then reducing your 'Contents' string into a set of smaller ones (<80k each) should stop them from being stored in the LOH.

提交回复
热议问题