Basically I am interested to know how far you go, to ensure your users get the best application.
- Which one to prefer dynamic/static memory allocation, when both are possible.
- Scraping
intand usingshortorint8_t. Will it really help? Or it would be more of a headache? - Allocating a “proportionally” large amount of memory dynamically (due to lack of info on actual memory required). And then reallocating it to smaller memory (compact) and deleting the former. Eg. I allocate 1000 units of memory. Then after calculating, I determine that only 400 units are required. So I allocate new 400 units, copy the 400 items and then delete 1000 units. In this process i end up allocating even more memory i.e 1400 units at some time. So should I actually take pains to allocate new 400 units and let 600 units waste? [main question]
- Any effective use of
unionto help lower memory usage?
I am sure there are more important points missing. Any other known or indigenous way to increase memory and time performance are welcome.
2. Static. Don't allocate memory when you don't need to.3. If the system is a 32-bit system, then the actual instructions to the processor will actually prefer uint32_t or int32_t...5. If I need a generic data type that would need to be allocated several times in a loop, then a union can come in handy... to avoid allocating memory.6. From my experience, allocating memory can be a slow process if it is done in a loop... You will see a performance increase if you allocate all the memory ahead of time, and then use it from a pool. When the system has go find huge blocks of memory, it can be a bottleneck.7. In real-time situations with large chunks of memory... yes... otherwise... eh... not reallyHope this helps… If you follow this style, you will notice improved performance.