Forum Discussion
Altera_Forum
Honored Contributor
14 years agoAssuming that the sections fit statically you should still evaluate if there is enough room for the stack and heap which grow and shrink at run time. I try to avoid using the heap if I can when possible (malloc allocates memory from the heap for example) since it's pretty difficult to determine what the maximum memory utilization is during run time.
If the stack or heap grow too much they'll collide and corrupt eachother. There are tests you can do to detect these like pre-populating your memory with 0xdeadbeef for example, running your code, then inspecting the memory to see if that pattern is still present where the heap and stack are located. If the pattern doesn't appear then the stack and heap either collided or touched. This test isn't perfect since it assumes during the run time of your code it reached it's maximum memory utilization which might not be true depending on outside factors. If you want to reduce your code footprint, take a look at the hello_world_small software template. It'll show you a limited stdio library and optimizations you can use.