edgexfoundry / device-sdk-c

Owner: Device WG
Apache License 2.0
42 stars 42 forks source link

Memory leak in devsdk_post_reading() function. #519

Open GabrielMonS opened 5 days ago

GabrielMonS commented 5 days ago

🐞 Bug Report

Affected Services [REQUIRED]

The issue is located in: device-sdk-c -> service.c (release 3.1.1) ### Is this a regression? N/A ### Description and Minimal Reproduction [**REQUIRED**] The devsdk_post_reading() function, used to generate events other than in response to GET requests or autoevents, appears to have a memory leak. The event is created using the edgex_data_process_event() function but it is never freed. This causes the memory to build up indefinetely. In order to reproduce this bug, use the devsdk_post_readings() function with a really big payload (I would recommend 10MB or so) every second. You shoudl see your RAM usage rapidly growing without ever going down. I just noticed the leak because I am sending images (some are 10+MB) at a very fast rate through the bus, and I saw my 32GB RAM memory fill up in a matter of minutes. ## 🔥 Exception or Error N/A ## 🌍 Your Environment **Deployment Environment: Ubuntu 22.04 for TuxedoOS** **EdgeX Version [**REQUIRED**]: 3.1.1 (NAPA)** **Anything else relevant?** It seems to be fixed just by adding ``` edgex_event_cooked_free (event); ``` before exiting the function. This frees the memory so no leaks happen, I have already tested my scenario with this modification and it seems to be fixed.
iain-anderson commented 5 days ago

This is fixed in #507 but not yet released

cloudxxx8 commented 2 days ago

@GabrielMonS please test with the C SDK v4.0.0-dev.1 tag

GabrielMonS commented 2 days ago

Thanks for reaching out! I will try to use the v4.0.0

El lun, 11 nov 2024 a las 3:50, Cloud Tsai @.***>) escribió:

@GabrielMonS https://github.com/GabrielMonS please test with the C SDK v4.0.0-dev.1 tag

— Reply to this email directly, view it on GitHub https://github.com/edgexfoundry/device-sdk-c/issues/519#issuecomment-2467128805, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7HG474Q3AIRAWDSTQ6HQGL2AALPJAVCNFSM6AAAAABRNVKRASVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRXGEZDQOBQGU . You are receiving this because you were mentioned.Message ID: @.***>

--

Gabriel Monteagudo Suárez

Ingeniero

tlf: +34 677226441

www.logicmelt.com

--

Este correo electrónico y, en su caso, cualquier fichero anexo al mismo, contiene información de carácter confidencial exclusivamente dirigida a su destinatario o destinatarios. Queda prohibida su divulgación, copia o distribución a terceros sin la previa autorización expresa y escrita de su autor. En el caso de haber recibido este correo electrónico por error se ruega que se notifique inmediatamente esta  circunstancia mediante reenvío a la dirección electrónica del remitente.

 

This email and, where appropriate, any file attached to it, contains confidential information exclusively addressed to its recipient or recipients. Its disclosure, copying or distribution to third parties without the express prior written authorization of its author is prohibited. In the event that you have received this email by mistake, please notify us immediately of this circumstance by forwarding it to the sender's email address.