开发者

How to reduce C# memory usage for Socket Application

开发者 https://www.devze.com 2023-02-13 03:54 出处:网络
I developed a simple UDP message server and client applicati开发者_高级运维on in Windows, the server can send a message to the client but the client can\'t send anything, they are only listening. the

I developed a simple UDP message server and client applicati开发者_高级运维on in Windows, the server can send a message to the client but the client can't send anything, they are only listening. the problem is the client application is use quite big memory usage is about 7M when it's listening and 9M when it received a packet. Could I reduce the memory usage into at least less then 1M?


How are you measureing your memory footprint? Any managed .net application, even the smallest typically has a shared working set of around 50 MBs, the actual memory footprint of your app is much smaller than that.

Have you tried calling GC.GetTotalMemory to look at the actual managed memory usage?


Much of this burden is the overhead of running the whole CLR system, garbage collection etc. If you're super-sensitive to memory footprint (<10-20Mb) then the CLR may not be for you. Even a basic HelloWorld private working set is over 4Mb of RAM.

If you are sensitive to footprint, you might be best served by looking to a true ahead-of-time compiled language like C/C++ etc.

0

精彩评论

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