This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Memory instrumentation for msp430 application

Hi all,

I'd like to add heap memory instrumentation to an msp430x application. At certain points I'd like to know the current heap usage, the maximum heap usage and the total available heap. Additinally, checking for memory corruptions when allocating and freeing memory should also be necessary.

What would be the recommended way to accomplish this? I was thinking about creating wrapper functions to the malloc/free/realloc functions and try adding the checking/accounting there or maybe modify/rebuild the run-time library so that these aspects are done inside the allocation functions themselves. The first approach I think means extra overhead both from speed and memory space perspective. The second one requires a rebuild of the library and I'm not sure that is a good idea.

Thanks and regards,

Alpar

  • TI has no solutions of its own to offer, nor any to recommend.  Sorry! 

    Thanks and regards,

    -George

     

  • Alpar,

    What you are looking for is sometimes called a 'high water mark', and is often part of the debug facility of most embedded OSes.  If you are using an embedded OS, check with the documentation.

    Otherwise, you don't have to modify the run-time libraries, just add a hook someplace convenient, like during a context switch.  

    Perhaps you could wrap calls to malloc and free in a macro that calls a vGetHighWaterMark() function first?  There is really no way to avoid the overhead of a wrapper function unless you have hardware support.  Often it is worth the tradeoff, though, depending on the criticality of your end application.

    Mateja