The way to know the memory leak on Jetson AGX Xavier

Hello,

Could you tell us the recommended way to know the memory leak on Jetson AGX Xavier?
During application running, the usage of the memory continues to increase on our development.
Although we tried to use Valgrind command to investigate; however, the command doesn’t seem to work fine on Jetson AGX Xavier.
So, if you know another way to know the memory leak, please let us know.

Best Regards,
NY

What’s I know is below

Kmemleak tool can be used for detecting kernel memory leaks.
In rel_32, related configs are already enabled.
#zgrep CONFIG_DEBUG_KMEMLEAK /proc/config.gz
CONFIG_DEBUG_KMEMLEAK=y
CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE=8000
# CONFIG_DEBUG_KMEMLEAK_TEST is not set
CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF=y
CONFIG_DEBUG_KMEMLEAK_SCAN_ON=y
Only below change only need to be done for enabling the feature in defconfig “arch/arm64/configs/tegra_defconfig”
-CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF=y
+# CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF is not set

Doc with details on how to use kmemleak is Kernel Memory Leak Detector — The Linux Kernel documentation

https://www.valgrind.org/docs/manual/quick-start.html
sudo apt-get install valgrind

valgrind --leak-check=yes myprog arg1 arg2

Hi Bibek-san,

Thank you for your reply.
We tried the command you wrote, but we cannot find what instruction causes error.
The information we need is what line in program cause the error.

Best Regards,
NY

what is the error?
Or you mean you can not find the memory leak?

Hello Bibek-san,

We tried evaluating by using the following test code.
#include <stdlib.h>

int main() {
char* test1 = (char *)malloc(sizeof(char) 4);
char
test2 = (char *)malloc(sizeof(char) *4);

    free(test2);
    free(test2);

}

The log of the valgrind command on x86 is the following.
x86_log.txt (1.7 KB)

The log of the valgrind command on Jetson is the following.
jetson_log.txt (1.5 KB)

In case of x86, we can find what function has the problem. It is shown in line starting with “by xxx”.
However, in case of jetson, we couldn’t find the line starting with “by xxx”, so we couldn’t find what function has the problem.

Do you know any procedure to know the function having problem?

Best Regards,
NY