NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform. You will still be able to view content, but posting and replying will be temporarily disabled.
We're excited to launch our new Community experience on July 30 and more information will follow soon.
Stay connected during the transition - Join our Discord community today.

Software Development Kit (SDK) and API Discussions

Valgrind reports possible memory leaks in na_startup.

sistemasgmv
3,760 Views

Hi all, I'm developing a little application in C using API version 5.1 and I use valgrind to detect memory leaks in my code. I have found a possible leak within the na_startup API call, just with the following code:

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <locale.h>

#include <netapp_api.h>

int main(void)

{

    char *StartupErrBuf;

    StartupErrBuf=(char *)calloc(256,sizeof(char));

    na_startup(StartupErrBuf,strlen(StartupErrBuf));

    free(StartupErrBuf);

    na_shutdown();

    exit(1);

}

valgrind reports 41 allocs and only 21 frees. I'm not an expert developer but I guess there are some intermediate allocs which are not freed or maybe I'm doing something wrong.

This is part of the report from valgrind when it is used to analyze the compiled binary from the above code:

==31653== HEAP SUMMARY:

==31653==     in use at exit: 268 bytes in 20 blocks

==31653==   total heap usage: 40 allocs, 20 frees, 1,106 bytes allocated

==31653==

==31653== 3 bytes in 1 blocks are still reachable in loss record 1 of 20

==31653==    at 0x4A0610C: malloc (vg_replace_malloc.c:195)

==31653==    by 0x4FDFCD2: pool_alloc (pool.c:266)

==31653==    by 0x4FEC1F7: str_cat (str.c:798)

==31653==    by 0x4FDEF21: path_initialize_dirs (path.c:203)

==31653==    by 0x4FDEDFF: path_init (path.c:154)

==31653==    by 0x4C17E15: na_startup (na.c:270)

==31653==    by 0x40072C: main (startup.c:12)

==31653==

==31653== 7 bytes in 1 blocks are still reachable in loss record 2 of 20

==31653==    at 0x4A0610C: malloc (vg_replace_malloc.c:195)

==31653==    by 0x4FDFCD2: pool_alloc (pool.c:266)

==31653==    by 0x4FEC1F7: str_cat (str.c:798)

==31653==    by 0x4FDEF42: path_initialize_dirs (path.c:204)

==31653==    by 0x4FDEDFF: path_init (path.c:154)

==31653==    by 0x4C17E15: na_startup (na.c:270)

==31653==    by 0x40072C: main (startup.c:12)

Any help will be very appreciated.

Regards,

Eduardo

2 REPLIES 2

sens
3,761 Views

Hi Eduardo,

We will look into the issue.

If it is indeed a memory leak, we will see if we can fix it in the upcoming releases of NMSDK.

Regards,

Sen.

sistemasgmv
3,760 Views

Hi Sen, thank you for your answer. I have several valgrind logs regarding this issue and I can send them to you if you need them. I have made several tests with NMSDK 5.1 and 5.2 versions with the same results.

Regards,

Eduardo

Public