Forum Discussion
Altera_Forum
Honored Contributor
14 years agoProfiling total memory usage in Nios II
Hi, everybody! A C program is running on a Nios II processor. At the rate of 100 ns, for instance, I need to catch the total memory the program is using, including there the text memory, the data ...
Altera_Forum
Honored Contributor
14 years ago1) If you are worried about memory footprint, it is best to avoid malloc() (ok malloc() is ok - just don't call free()!) then it memory can't run out at inopportune moments.
2) Code, data, bss and other segments sizes can be found from 'objdump -h' or 'size -A' (and other requests) on the final image. 3) Stack use is more problematic. If you have no recursive calls and no calls via function pointers it is possible to write a C program to analise the generated code to sort out the call graph and stack level at each call. I process the output of 'gcc -S -fverbose-asm ...' in order to statically count the worst case execution time of my code (there are no function calls in it!) I also use a few asm statements to mark some paths as 'to be ignored'.