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 allocation changing other variables on the heap

Other Parts Discussed in Thread: TMS320C6416T

I am working on a TMS320C6416T DSK and I have a problem where when I allocate some memory using calloc it is changing the values stored in other heap variables.  I have tried changing the sizes of the stack and heap and moving the heap onto the SDRAM instead of the ISRAM, but nothing seems to fix the problem.  How can I determine what is causing the problem?

Thanks,

Susan

 

  • Sorry, I figured it out.  My stack was not large enough to contain the large array I had allocated on the stack and this was messing things up.  Is there a way to detect this problem easily in the future?

     

    Thanks,

    Susan

  • Stack overflows are a pretty common issue, but I have never seen a perfect way to detect them automagically. My best advice is to fill the stack with a known value and if you run into an unexplainable issue check to see if the value at the top of the stack has changed. If it has then you know that the stack has hit the top and more than likely overflowed.