I got a message through event handle and I wanna send it through queue.
I know the queue will copy memory in FreeRTOS but the msg.data is a pointer so the memory that the pointer points will not be copied.
I wanna know what time the pointer will be free ? Should I copy the memory that the pointer points manually and free it after queue send.
The life cycle of data arriving via MQTT_EVENT_DATA
-
- Posts: 16
- Joined: Fri Aug 16, 2024 1:55 am
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: The life cycle of data arriving via MQTT_EVENT_DATA
It won't be, not by FreeRTOS that is. If you push a pointer into a queue, FreeRTOS will just handle it as it would handle any opaque data, it doesn't know it's a pointer. You would normally free it after you receive it and are done with it.
-
- Posts: 16
- Joined: Fri Aug 16, 2024 1:55 am
Re: The life cycle of data arriving via MQTT_EVENT_DATA
What I mean is, the MQTT message I get through the event function (from MQTT), its data is a pointer, I send this message through the queue, then the data memory will not be copied, do I need to copy this memory to avoid it being released by the MQTT task? My question is about the life cycle of data in MQTT messages, not freertosESP_Sprite wrote: ↑Fri Aug 16, 2024 3:41 amIt won't be, not by FreeRTOS that is. If you push a pointer into a queue, FreeRTOS will just handle it as it would handle any opaque data, it doesn't know it's a pointer. You would normally free it after you receive it and are done with it.
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: The life cycle of data arriving via MQTT_EVENT_DATA
Ah, gotcha. Generally you cannot assume the lifetime of any data passed into a callback exists past the duration of a callback; the documentation will explicitly mention it if it does persist longer.
-
- Posts: 16
- Joined: Fri Aug 16, 2024 1:55 am
Re: The life cycle of data arriving via MQTT_EVENT_DATA
Got it! Thanks for ur response.ESP_Sprite wrote: ↑Sat Aug 17, 2024 5:45 amAh, gotcha. Generally you cannot assume the lifetime of any data passed into a callback exists past the duration of a callback; the documentation will explicitly mention it if it does persist longer.
BEST REGARD.
Who is online
Users browsing this forum: Baidu [Spider], KaosESP32 and 171 guests