Memory-saving tips and tricks
System programmers need to be aware of the memory that’s used by the systems they write on. So, I want to share tips that will help you reduce memory pressure. Memory pressure is a fancy word to indicate how much memory is used compared to the amount of memory available. Again, some of these tips will make your system slower. As a system programmer, you must make informed choices and trade-offs between fast and memory-efficient code writing. Sometimes, you get lucky, and you get both. Other times, you must look at the options and pick the lesser of two evils. The following will cover specific things you can do to reduce memory pressure on your system.
- Use value types over reference types: Values types on the stack are usually smaller than reference types. The overhead of the pointer to the class and the pointers in the heap themselves can be a reason to move to value types, such as structs, instead of using reference types, such as classes...