简体   繁体   中英

How to reduce C# memory usage for Socket Application

I developed a simple UDP message server and client application 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM