When is it acceptable to call GC.Collect?

前端 未结 24 2175
挽巷
挽巷 2020-11-22 08:54

The general advise is that you should not call GC.Collect from your code, but what are the exceptions to this rule?

I can only think of a few very speci

24条回答
  •  长发绾君心
    2020-11-22 09:18

    one good reason for calling GC is on small ARM computers with little memory, like the Raspberry PI (running with mono). If unallocated memory fragments use too much of the system RAM, then the Linux OS can get unstable. I have an application where I have to call GC every second (!) to get rid of memory overflow problems.

    Another good solution is to dispose objects when they are no longer needed. Unfortunately this is not so easy in many cases.

提交回复
热议问题