powerapi-ng / hwpc-sensor

Hardware Performance Counters monitoring agent for containers.
BSD 3-Clause "New" or "Revised" License
14 stars 16 forks source link

Potential memory leak #18

Closed PierreRustOrange closed 2 years ago

PierreRustOrange commented 2 years ago

When stopping the sensor, I generally get a warning such as this :

=================================================================
==1055067==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 3174400 byte(s) in 775 object(s) allocated from:
    #0 0x7f4e13fc5720 in __interceptor_realloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xe9720)
    #1 0x7f4e13e49d6e in bson_realloc (/usr/lib/x86_64-linux-gnu/libbson-1.0.so.0+0x1ed6e)

SUMMARY: AddressSanitizer: 3174400 byte(s) leaked in 775 allocation(s).

The sensor is running with the socket output.

PierreRustOrange commented 2 years ago

I thinks it grow larger the longer the sensor run. For example, after 10 min I get :

=================================================================
==1055615==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 14958592 byte(s) in 3652 object(s) allocated from:
    #0 0x7fde2de72720 in __interceptor_realloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xe9720)
    #1 0x7fde2dcf6d6e in bson_realloc (/usr/lib/x86_64-linux-gnu/libbson-1.0.so.0+0x1ed6e)

SUMMARY: AddressSanitizer: 14958592 byte(s) leaked in 3652 allocation(s).

and after 1h14:

=================================================================
==1056597==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 100581376 byte(s) in 24556 object(s) allocated from:
    #0 0x7f802a19d720 in __interceptor_realloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xe9720)
    #1 0x7f802a021d6e in bson_realloc (/usr/lib/x86_64-linux-gnu/libbson-1.0.so.0+0x1ed6e)

SUMMARY: AddressSanitizer: 100581376 byte(s) leaked in 24556 allocation(s).
PierreRustOrange commented 2 years ago

PR #21 fixes this (I tested for a few minutes and no leak was reported).