Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Paho » Memory leaks in async MQTT C client(found some memory leaks when publishing messages and receiving content from subscriptions)
Memory leaks in async MQTT C client [message #1796355] Thu, 11 October 2018 14:23 Go to next message
Alois Schausberger is currently offline Alois SchausbergerFriend
Messages: 5
Registered: August 2018
Junior Member
I had some memory leaks in my application, where the asynchronouus MQTT C client was used in an environment with the extended diagnostic tools (Visual Studio 2017, an application with MFC Dll linked).
The diagnostic tools showed some memory leaks which I could identify and solve (I think the solution is a crude hack and should finally be solved from your side).
Enclosed you will find some source where I made changes.
In HeapX I provided an interface to inject memory allocation protocol feature, which was usefull to track all memory handlings in the module test (in heap.h this extension is activated dependent to the constant EXT_HEAP_TRACKING).
MQTTAsync.c contains the changes I mode to prevent the memory leaks to happen.
Changes I have done are on lines 1356, 2022 ans 2281.
Please try to provide the final adaptions to the source so that I can include them in my product (same as with issue with openSSL).
  • Attachment: HeapX.c
    (Size: 0.88KB, Downloaded 117 times)
  • Attachment: Heap.h
    (Size: 2.70KB, Downloaded 127 times)
  • Attachment: MQTTAsync.c
    (Size: 90.48KB, Downloaded 198 times)
Re: Memory leaks in async MQTT C client [message #1796363 is a reply to message #1796355] Thu, 11 October 2018 15:45 Go to previous messageGo to next message
Ian Craggs is currently offline Ian CraggsFriend
Messages: 83
Registered: March 2013
Member
Hi. The fixes would be better handled as a Pull Request on Github, where regression tests will be automatically run on the changes. Do you have a test or tests which exhibit the problem, so they could be added to the test suite?

I'm not sure what point of the functions in HeapX.c are, given that memory tracking is already done in Heap.c. The results of those allocations/frees are shown in the trace output (see the readme for how to generate).
Re: Memory leaks in async MQTT C client [message #1796364 is a reply to message #1796363] Thu, 11 October 2018 15:55 Go to previous message
Alois Schausberger is currently offline Alois SchausbergerFriend
Messages: 5
Registered: August 2018
Junior Member
You're right - I have seen the heap trace support in heap.c and heap.h. I did it with HeapX because I had already an efficient tool for tracking the memory allocations and providing also some evaluations. I added it for completness.
The module test program is a complex regression test run, which will be used later in our automated test environment. I will speak with our PO and ask him to let me make a simple version of some tests, so that I can show the situations where the erros happen.
I would prefer you could do a pull request because I do not know what side effects may happen with my changes. The first one (line 1356) is really a hack. I do not know what the intention of the statemaent was which I commented out. Changes 2 and 3 may be good but I think you and your team will have a better judgement about that changes.
Previous Topic:Memory leaks in openssl
Next Topic:Basic MQTT over websockets example
Goto Forum:
  


Current Time: Sat Apr 27 04:35:36 GMT 2024

Powered by FUDForum. Page generated in 0.03746 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top