This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Catching memory leaks

I have some code running on an 8051 based processor that is quite large and complex and it also uses a few arrays. To make sure that I can avoid mistakes accessing memory location that do not exist, I'd like to know if there are anyway to get the C51 Compiler to catch this type of mistakes.

BYTE xdata myArray[8]
BYTE i;

for (i=0;i<10;i++)
    myArray[i]=i;

The compiler has no problem with that and doesn't report memory leaks. Are there any ways to make the compiler to generate an error or even a warning?

Parents
  • 1) that is not what I call memory leaks, It is BUGS.
    2) the example you give is BAD, it uses a numeric value which should make it obvious that this is wrong.
    3) it not ythe purpose of a compiler to protect you against yourself
    4)it is very easy to do a thing like
    #ifdef DEBUG
    if (var > sizeof myArray)
    { make the program error out
    } #endif

    Erik

Reply
  • 1) that is not what I call memory leaks, It is BUGS.
    2) the example you give is BAD, it uses a numeric value which should make it obvious that this is wrong.
    3) it not ythe purpose of a compiler to protect you against yourself
    4)it is very easy to do a thing like
    #ifdef DEBUG
    if (var > sizeof myArray)
    { make the program error out
    } #endif

    Erik

Children