Topic: Heap Usage in WolfMQTT

Hello

I am new to the WolfMqtt library and I am in the phase of evaluating it for the usage as mqtt v5 client library.
I will use WolfMqtt based on Zephyr OS and I was able to get the two sample applications in Zephyr folder to run successfully.

So here is my questions:
1- One of my hard requirements is no heap usage at all, and I noticed that there are couple of malloc calls or to be more specifically WOLFMQTT_MALLOC used, so the first question is there any way to configure the WolfMqtt to not use the heap ? I couldn't find anything in documentation discussing the memory usage of WolfMqtt.

2- In case of TLS Usage and the integration of WolfSSL with my WolfMQTT application, I have seen that there this configuration parameter WOLFSSL_NO_MALLOC that disables the heap memory utilization, so my question is: Is my understanding correct that this configuration parameter completely disables the heap utilization, since I have seen alot of malloc calls in WolfSSL not protected by WOLFSSL_NO_MALLOC conditional compilation.

Share

Re: Heap Usage in WolfMQTT

Hello mabduljawad

Thanks for joining the wolfSSL forums! The wolfMQTT library will only use malloc if configured to allocate MQTTv5 properties dynamically. By default, the library is stack-only.

For wolfSSL, check out the static memory guide:
https://www.wolfssl.com/docs/static-buffer-allocation/

Could you tell us a bit about your MQTT project? Feel free to email support@wolfssl.com for a more private discussion.

Thanks,
Eric - wolfSSL Support

Re: Heap Usage in WolfMQTT

Hello Eric

Thank you for your reply.

Yes ofcourse I can, I will get in touch with the support mail.

Share

4 (edited by joedavenportjd25 2024-10-03 07:38:41)

Re: Heap Usage in WolfMQTT

In my opinion, your two cases should be resolved like this:

1. Disabling heap usage in WolfMQTT: While WolfMQTT uses dynamic memory allocation through WOLFMQTT_MALLOC, the library doesn't have a built-in option to entirely avoid heap usage. However, you can modify the behavior by redefining WOLFMQTT_MALLOC, WOLFMQTT_FREE, and WOLFMQTT_REALLOC macros to use static memory or pre-allocated buffers. This would allow you to run the library without relying on heap memory.
                                          geometry dash meltdown
2. TLS and WolfSSL (WOLFSSL_NO_MALLOC): Yes, your understanding is correct. The WOLFSSL_NO_MALLOC configuration is meant to disable heap usage. However, not all malloc calls are guarded by this macro, so while it reduces dynamic memory usage, you may still need to review the code and ensure that no heap allocations occur where WOLFSSL_NO_MALLOC isn't applied. In this case, you can manually replace or adjust these calls to use static memory.

Regard,
joedavenportjd25

Share