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.

CCS/CC2642R: Heap memory leak after connecting and disconnecting

Part Number: CC2642R

Tool/software: Code Composer Studio

Hi,

On every connect + disconnect, the MCU loses 8 bytes of heap memory.

Here are the steps to reproduce:

1. run ble5_simple_peripheral_cc26x2r2lp_app project on the relevant LaunchPad.

2. constantly print the total free size of the heap using 

uint32_t heap_now = heap_stat.totalFreeSize;
Display_print1(dispHandle, 15, 0, "heap now: 0x%x", heap_now);

3. notice: the free heap size before connecting is larger in 8 bytes than the total free heap size after disconnecting. 

I've noticed you skip in your code on the deallocation of connHandle:

case SP_SEND_PARAM_UPDATE_EVT:
    {
      // Extract connection handle from data
      uint16_t connHandle = *(uint16_t *)(((spClockEventData_t *)pMsg->pData)->data);

      SimplePeripheral_processParamUpdate(connHandle);

      // This data is not dynamically allocated
      dealloc = FALSE;
      break;
    }

What makes sense since we're still in connection on that point. But, I haven't notices the deallocation anywhere else... is that might be it?

I would appreciate your help,

Amit

  • Hi Amit,

    Thanks for reporting this. It turns out that it's the paramUpdateEventData allocated in SimplePeripheral_addConn that isn't deallocated.

    As a sort of hack, you can add ICall_free(pUpdateClock->f6); before Clock_destruct in SimplePeripheral_removeConn(..) and ICall_free(connList[connIndex].pUpdateClock->f6); in SimplePeripheral_processParamUpdate(...)

    I've reported this to the development team. Thanks again.

    Best regards,
    Aslak