Valgrind reports memory leakage on

Software versions:
CUDA: 10.2/11.4
Valgrind: 3.19.0

Problem description
We use valgrind to test memory leaks on our programs, and valgrind reports 72704 bytes of memory leakage, the problem is caused by

Here is a minimal example to reproduce the problem. This small example just dlopen the shared library and close it immediately.

#include <cstdio>
#include <dlfcn.h>

int main() {
    void* handle = dlopen("/usr/local/cuda/targets/aarch64-linux/lib/", RTLD_NOW);
    if (!handle) {
        fprintf(stderr, "load failed");
        return -2;

and compile using

g++ main.cpp -o main -ldl

and run valgrind memory leak check

valgrind --tool=memcheck --leak-check=full --keep-debuginfo=yes -- ./main

The result is

==451089== 72,704 bytes in 1 blocks are definitely lost in loss record 6 of 6
==451089==    at 0x4849D8C: malloc (in /usr/lib/aarch64-linux-gnu/valgrind/
==451089==    by 0x4FCD33B: ??? (in /usr/local/cuda-11.4/targets/aarch64-linux/lib/
==451089== LEAK SUMMARY:
==451089==    definitely lost: 72,704 bytes in 1 blocks
==451089==    indirectly lost: 0 bytes in 0 blocks
==451089==      possibly lost: 0 bytes in 0 blocks
==451089==    still reachable: 3,189 bytes in 10 blocks
==451089==         suppressed: 0 bytes in 0 blocks
==451089== Reachable blocks (those to which a pointer was found) are not shown.
==451089== To see them, rerun with: --leak-check=full --show-leak-kinds=all


Thanks for reporting this.
Confirmed that we can reproduce this memory leakage issue in the JetPack5 environment.

We are going to check this with our internal team.
Will share more information with you later.



We have checked this issue with our internal team.

The memory leak is in the c++ library runtime emergency pool:
The source code of

262 pool emergency_pool;

It is intentional the emergency_pool not be released.
So in the case at exit() time memory is exhausted, it can use emergency_pool.


How do you locate the issue? Is from backtrace?
We want to reproduce it.



Sorry that this is captured by running Valgrind with the nvrtc source.
But the library is not open-sourced.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.