Bug#1138267: nvtop: Memory leak with Intel GPU

Alexander Inyukhin shurick at sectorb.msk.ru
Sat May 30 10:17:57 BST 2026


Package: nvtop
Version: 3.2.0-1
Severity: normal
Tags: patch

Dear nvtop maintainers!

I have identified two separate memory leaks within nvtop 3.2.0-1.
These leaks occur under specific circumstances and can lead to increased
memory usage over time.

The first leak appears to occur within the hardware monitoring (hwmon)
enumeration code. Specifically, the enumerator object is not properly
freed when errors are encountered during enumeration, resulting in a
leak.

The second leak is related to the handling of temporary object during
dynamic data updates on intel gpus. This object is created and used but not
subsequently deallocated.

I have attached the output of `valgrind --leak-check=full nvtop -s`
which demonstrates these memory leaks.

I have developed patches to address both of these issues. The patches
ensure proper cleanup of the enumerator object in the hwmon enumeration
code and correct the deallocation of temporary objects used in dynamic
data updates.

Attachments:
* `valgrind_output.txt` (Output from `valgrind --leak-check=full nvtop -s`)
* `hwmon_leak_fix.patch` (Patch for hwmon enumeration leak)
* `dynamic_data_leak_fix.patch` (Patch for dynamic data update leak)

I would greatly appreciate it if you would consider reviewing and
applying these patches to resolve these memory leak issues in future
releases of nvtop.

Thank you for your time and consideration.
-------------- next part --------------
==23439== Memcheck, a memory error detector
==23439== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==23439== Using Valgrind-3.24.0 and LibVEX; rerun with -h for copyright info
==23439== Command: nvtop -s
==23439== Parent PID: 27598
==23439== 
==23439== 
==23439== HEAP SUMMARY:
==23439==     in use at exit: 2,517 bytes in 14 blocks
==23439==   total heap usage: 3,792 allocs, 3,778 frees, 4,738,699 bytes allocated
==23439== 
==23439== 300 (144 direct, 156 indirect) bytes in 1 blocks are definitely lost in loss record 11 of 14
==23439==    at 0x4844818: malloc (vg_replace_malloc.c:446)
==23439==    by 0x49EAC36: sd_device_enumerator_new (in /usr/lib/x86_64-linux-gnu/libsystemd.so.0.40.0)
==23439==    by 0x120571: nvtop_enumerator_new (device_discovery_linux.c:251)
==23439==    by 0x120571: nvtop_device_get_hwmon (device_discovery_linux.c:342)
==23439==    by 0x124EDC: add_intel_cards (extract_gpuinfo_intel.c:111)
==23439==    by 0x124EDC: gpuinfo_intel_get_device_handles (extract_gpuinfo_intel.c:156)
==23439==    by 0x11BD56: gpuinfo_init_info_extraction (extract_gpuinfo.c:66)
==23439==    by 0x1110DB: main (nvtop.c:211)
==23439== 
==23439== 585 (416 direct, 169 indirect) bytes in 1 blocks are definitely lost in loss record 12 of 14
==23439==    at 0x4844818: malloc (vg_replace_malloc.c:446)
==23439==    by 0x49FB7E1: ??? (in /usr/lib/x86_64-linux-gnu/libsystemd.so.0.40.0)
==23439==    by 0x124876: gpuinfo_intel_refresh_dynamic_info (extract_gpuinfo_intel.c:242)
==23439==    by 0x11BE09: gpuinfo_refresh_dynamic_info (extract_gpuinfo.c:103)
==23439==    by 0x117368: print_snapshot (interface.c:2061)
==23439==    by 0x1115CF: main (nvtop.c:219)
==23439== 
==23439== LEAK SUMMARY:
==23439==    definitely lost: 560 bytes in 2 blocks
==23439==    indirectly lost: 325 bytes in 9 blocks
==23439==      possibly lost: 0 bytes in 0 blocks
==23439==    still reachable: 1,632 bytes in 3 blocks
==23439==         suppressed: 0 bytes in 0 blocks
==23439== Reachable blocks (those to which a pointer was found) are not shown.
==23439== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==23439== 
==23439== For lists of detected and suppressed errors, rerun with: -s
==23439== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0009-Free-enumerator-on-errors.patch
Type: text/x-diff
Size: 1201 bytes
Desc: hwmon_leak_fix.patch
URL: <http://alioth-lists.debian.net/pipermail/pkg-nvidia-devel/attachments/20260530/ae362e1b/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0010-Free-bridge_dev-on-intel.patch
Type: text/x-diff
Size: 1069 bytes
Desc: dynamic_data_leak_fix.patch
URL: <http://alioth-lists.debian.net/pipermail/pkg-nvidia-devel/attachments/20260530/ae362e1b/attachment-0001.patch>


More information about the pkg-nvidia-devel mailing list