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.

CC2540: Will the memory allocated by GATT_bm_alloc be released automatically while successfully calling GATT_Notification?

Part Number: CC2540


I'm coding to test the GATT_Notification function according to below example. But found that the example didn't release the allocated memory after GATT_Notification is successfully executed. But when I wrote a test code to notify automatically every 100ms, and found that no error occurs, and the heap is still having enough space. So the question is, can I see the allocated memory will be released automatically and no need to release manually?

So I'm guessing the GATT_Notification function could release the memory automatically. But I've not found any reference since TI's GATT manual didn't say a thing about it.

This is really an old chip, so many thanks that if anyone could help me to clarify it.

  • Hi Weichen,

    Please see the Memory Management for GATT Notifications/Indications section (Section 7.6.1) )of the TI BLE Software Developer's Guide for information about how memory is freed for notifications/indications.
  • Rachel,

    Thank you so much for your help. It helps.

    The Software Developer's Guide's already pointed it out and I should read it carefully. And I'm posting the text below for other guys to refer.

    7.6.1 Memory Management for GATT Notifications / Indications

    The preferred method to send a GATT notification / indication is to use a profile’s SetParameter

    function (i.e. SimpleProfile_SetParameter()) and call GATTServApp_ProcessCharCfg(). If using

    GATT_Notification() or GATT_Indication() directly, there is additional memory management needed:

    1. Attempt to allocate memory for the notification / indication using GATT_bm_alloc().

    2. If allocation succeeds, send notification / indication using GATT_Notification() /

    GATT_Indication().

    3. If the return value of the notification / indication is SUCCESS (0x00), this means the memory was

    freed by the stack. If the return value something other than SUCCESS (i.e. blePending), free the

    memory using GATT_bm_free()