[csharp] Performance #2
GC stressed
This problem can occur with real-time systems and can be mitigated by doing Memory Management optimizations such as:
- Pre-allocating memory or use Object Pools
- Allocate smaller memory objects to avoid memory fragmentation
tips
- Use non-blocking system calls when working with I/O.
- Replace dedicated user threads with tasks which run on the ThreadPool
- Use pre-allocated fixed size arrays
- Do not use
IEnumerable<T>
in hot code paths - Use StringBuilder when concatinating strings.
- Value types vs Reference types
Hidden performance
If you are planning to build a high performance TCP server and client do not leave out System.Net.Sockets.SocketAsyncEventArgs. Or are you working on software that processes allot of I/O in general it is worth noting to consider System.IO.Pipelines.
TLDR; Most importantly is when developing software using a memory managed language such as csharp or java, engineers must be aware of memory allocation. If the GC (garbage collector) is stressed to much, you are going to have a fun time ready this post. 😊
cture was not prepared for it an even when increasing CPU and RAM resources (vertical scaling) it fails to perform.
- Inline functions (AggressiveInline)