Tool/software: TI C/C++ Compiler
description:
CCS Version: 7.0.0.00042
C2800 Compiler Tools 16.9.1.LTS
the program always down, with the malloc failure:
what the program is doing is to receive USB message (with about 140 bytes payload), then break it down to CAN messages (up to 8 byte payload), and forward the CAN message reply from device to the USB port.
there's some malloc( ) and free( ) in the code.
I allocated a big heap size (len: 0x2000, from 0xA000) in the linker configuration
.esysmem 1 0000a000 00002000 UNINITIALIZED
0000a000 00000001 rts2800_fpu32.lib : memory.obj (.esysmem)
0000a001 00001fff --HOLE-
I also wrote a array to record the start address and length of allocated memory for each malloc / delete operation.
bool recordMalloc(Uint32 startAddr, Uint32 len)
{
#ifdef MEMORY_RECORD_LEN
int i;
for (i=0; i<MEMORY_RECORD_LEN; i++) {
if (memory_record[i].len == 0) {
memory_record[i].startAddr = startAddr;
memory_record[i].len = len;
return true;
}
}
return false;
#endif
}
bool recordFree(Uint32 startAddr)
{
#ifdef MEMORY_RECORD_LEN
int i;
for (i=0; i<MEMORY_RECORD_LEN; i++) {
if (memory_record[i].startAddr == startAddr) {
memory_record[i].startAddr = 0;
memory_record[i].len = 0;
return true;
}
}
return false;
#endif
}
I find that when the program dies there seems no memory leakage:
it's still tons of heap memory left.
Any clue? thanks.