开发者

memory usage in C# (.NET) app is very high, until I call System.GC.Collect()

开发者 https://www.devze.com 2022-12-27 21:12 出处:网络
I\'ve written an app that spins a few threads each of which read several MB of memory.Each thread then con开发者_如何学Cnects to the Internet and uploads the data.this occurs thousands of times and ea

I've written an app that spins a few threads each of which read several MB of memory. Each thread then con开发者_如何学Cnects to the Internet and uploads the data. this occurs thousands of times and each upload takes some time

I'm seeing a situation where (verified with windbg/sos and !dumpheap) that the Byte[] are not getting collected automatically, causing 100/150MB of memory to be reported in task manager

if I call System.GC.Collect() i'm seeing a huge drop in memory, a drop of over 100MB

I dont like calling System.GC.Collect() and my PC has tons of free memory. however if anyone looks at TaskManager they're going to be concerned, thinking my app is leaking horribly.

tips?


The runtime is taking advantage of a large amount of free memory to reduce the impact of the garbage collector on the performance of your application. The "problem" here is a general lack of understanding (e.g. your users) that when a system has more memory, it's ok to use it (otherwise what's the point?).


Problem is, some users do check the memory and cpu usage, and reports your application is consuming too much even when there is no problem with their performance. I think they do this to show their boss/girlfriend/fellows how much they know about computers.

A carefully placed CG.Collect in your app will probably reduce this human (not computer) problem. I think you should do it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号