Valgrind "still reachable bytes" after API calls

Hi,
Looks like some of the allocated bytes aren’t getting free’d when calling some of the API functions, such as: confd_init, confd_ha_connect, confd_ha_bemaster, confd_ha_beslave, etc…

I have confd basic 5.4.
I compiled the example examples.confd/ha/dummy with make all. Then make start.
Now, for example, when running the following command:

valgrind --leak-check=full --show-reachable=yes ./ctrl master node0
I get this output:

==31528== Memcheck, a memory error detector
==31528== Copyright (C) 2002-2010, and GNU GPL’d, by Julian Seward et al.
==31528== Using Valgrind-3.6.0 and LibVEX; rerun with -h for copyright info
==31528== Command: ./ctrl master node0
==31528==
==31528== HEAP SUMMARY:
==31528== in use at exit: 868 bytes in 8 blocks
==31528== total heap usage: 13 allocs, 5 frees, 917 bytes allocated
==31528==
==31528== 4 bytes in 1 blocks are still reachable in loss record 1 of 8
==31528== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==31528== by 0x41DB79: confd_errno_location (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x41DBA5: clr_confd_err (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x40D527: confd_do_connect (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x4139DF: confd_ha_connect (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x402E6B: bemaster (ctrl.c:127)
==31528== by 0x4037BE: main (ctrl.c:301)
==31528==
==31528== 8 bytes in 1 blocks are still reachable in loss record 2 of 8
==31528== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==31528== by 0x4444AC: ei_mutex_create (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x4443E5: erl_init_eterm_alloc (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x42F3B8: erl_init (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x41BBB1: confd_init_vsn_sz (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x4036E8: main (ctrl.c:256)
==31528==
==31528== 32 bytes in 1 blocks are still reachable in loss record 3 of 8
==31528== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==31528== by 0x4443BA: erl_init_eterm_alloc (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x42F3B8: erl_init (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x41BBB1: confd_init_vsn_sz (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x4036E8: main (ctrl.c:256)
==31528==
==31528== 40 bytes in 1 blocks are still reachable in loss record 4 of 8
==31528== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==31528== by 0x44394A: ei_m_create (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x4444B9: ei_mutex_create (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x4443E5: erl_init_eterm_alloc (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x42F3B8: erl_init (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x41BBB1: confd_init_vsn_sz (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x4036E8: main (ctrl.c:256)
==31528==
==31528== 88 bytes in 1 blocks are still reachable in loss record 5 of 8
==31528== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==31528== by 0x44438E: erl_eterm_alloc (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x430477: erl_alloc_eterm (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x42DDAC: erl_mk_int (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x420155: ha_order_node (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x402E99: bemaster (ctrl.c:128)
==31528== by 0x4037BE: main (ctrl.c:301)
==31528==
==31528== 88 bytes in 1 blocks are still reachable in loss record 6 of 8
==31528== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==31528== by 0x44438E: erl_eterm_alloc (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x430477: erl_alloc_eterm (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x42E052: erl_mk_binary (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x417FC7: val_to_term (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x420167: ha_order_node (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x402E99: bemaster (ctrl.c:128)
==31528== by 0x4037BE: main (ctrl.c:301)
==31528==
==31528== 88 bytes in 1 blocks are still reachable in loss record 7 of 8
==31528== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==31528== by 0x44438E: erl_eterm_alloc (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x430477: erl_alloc_eterm (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x42DF81: erl_mk_tuple (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x42017E: ha_order_node (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x402E99: bemaster (ctrl.c:128)
==31528== by 0x4037BE: main (ctrl.c:301)
==31528==
==31528== 520 bytes in 1 blocks are still reachable in loss record 8 of 8
==31528== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==31528== by 0x4A06167: realloc (vg_replace_malloc.c:525)
==31528== by 0x41DABC: get_lasterr (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x41DB1A: confd_lasterr (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x41DBAD: clr_confd_err (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x40D527: confd_do_connect (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x4139DF: confd_ha_connect (in /home/yogev/confd_basic_5_4/examples.confd/ha/dummy/ctrl)
==31528== by 0x402E6B: bemaster (ctrl.c:127)
==31528== by 0x4037BE: main (ctrl.c:301)
==31528==
==31528== LEAK SUMMARY:
==31528== definitely lost: 0 bytes in 0 blocks
==31528== indirectly lost: 0 bytes in 0 blocks
==31528== possibly lost: 0 bytes in 0 blocks
==31528== still reachable: 868 bytes in 8 blocks
==31528== suppressed: 0 bytes in 0 blocks

It happens also for “slave” and “none”…
Thanks,
Yogev.

From the ConfD UG Chapter “General Troubleshooting Strategies”:

When debugging application memory leaks with a tool like valgrind, it is often necessary to rebuild libconfd from source, since the default build uses a “pool allocator” that makes the stack trace information for memory leaks from valgrind completely misleading for allocations from libconfd. The details of how to do a build that disables the pool allocator are described in the “Application debugging” section of the README in the libconfd source package.

The ConfD Basic libconfd source package tarball is called confd-basic-X.X.libconfd.tar.gz

Hi again.
I tried to rebuild the libconfd.a but there is still inconsistency between the allocated and frees from valgrind point of view.

My simple code example is (even though, there’s a leak also only for main() with the code: confd_init()):

#include <stdio.h>
#include <confd_lib.h>
#include <confd_cdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>

int main() {

        struct sockaddr_in addr;
        int sock;
        char *confd_addr = "127.0.0.1";
        int confd_port = CONFD_PORT;

        addr.sin_addr.s_addr = inet_addr(confd_addr);
        addr.sin_family = AF_INET;
        addr.sin_port = htons(confd_port);

        confd_init("valgrind", stderr, CONFD_TRACE);

        if ((sock = socket(PF_INET, SOCK_STREAM, 0)) < 0)
                confd_fatal("Failed to create socket");

        if (confd_load_schemas((struct sockaddr*)&addr, sizeof (struct sockaddr_in)) != CONFD_OK)
                confd_fatal("Failed to load schemas from confd");

        if (cdb_connect(sock, CDB_DATA_SOCKET, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) != CONFD_OK)
                confd_fatal("Failed to connect to ConfD");

        cdb_close(sock);

        printf("finished\n");
}

I compile it using:

gcc -o main main.c -I/confd/include -pthread libconfd.a

When I run it with valgrind:

valgrind --leak-check=full --show-reachable=yes --track-origins=yes ./main

I get the output (summary, the rest is in the end):

==19422== HEAP SUMMARY:
==19422==     in use at exit: 274,458 bytes in 5,024 blocks
==19422==   total heap usage: 13,747 allocs, 8,723 frees, 603,677 bytes allocated

Now, I read the README file, and compiled libconfd.a with export NO_FIX_ALLOC=yes, then make
I compiled my code with:

gcc -o main main.c -I/confd/include -pthread libconfd_NO_FIX_ALLOC.a

I repeated the process and the valgrind’s output was (summary, the rest is in the end):

==19437== HEAP SUMMARY:
==19437==     in use at exit: 178,802 bytes in 3,937 blocks
==19437==   total heap usage: 32,933 allocs, 28,996 frees, 1,967,677 bytes allocated

Is there’s something I’m doing wrong?
Thanks.

libconfd_normal

==19422== Memcheck, a memory error detector
==19422== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==19422== Using Valgrind-3.6.0 and LibVEX; rerun with -h for copyright info
==19422== Command: ./main
==19422==
TRACE Connected (maapi) to ConfD
TRACE MAAPI_LOAD_ALL_NS
TRACE MAAPI_LOAD_HASH_DB
TRACE Connected (cdb) to ConfD
finished
==19422==
==19422== HEAP SUMMARY:
==19422==     in use at exit: 274,458 bytes in 5,024 blocks
==19422==   total heap usage: 13,747 allocs, 8,723 frees, 603,677 bytes allocated
==19422==
==19422== 4 bytes in 1 blocks are still reachable in loss record 1 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x41C8A9: confd_errno_location (in /home/valgrind/test/main)
==19422==    by 0x41C8D5: clr_confd_err (in /home/valgrind/test/main)
==19422==    by 0x40C257: confd_do_connect (in /home/valgrind/test/main)
==19422==    by 0x4414EA: maapi_connect (in /home/valgrind/test/main)
==19422==    by 0x41186D: get_maapi_sock (in /home/valgrind/test/main)
==19422==    by 0x41196E: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 8 bytes in 1 blocks are still reachable in loss record 2 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x4431DC: ei_mutex_create (in /home/valgrind/test/main)
==19422==    by 0x443115: erl_init_eterm_alloc (in /home/valgrind/test/main)
==19422==    by 0x42E0E8: erl_init (in /home/valgrind/test/main)
==19422==    by 0x41A8E1: confd_init_vsn_sz (in /home/valgrind/test/main)
==19422==    by 0x4024CA: main (in /home/valgrind/test/main)
==19422==
==19422== 15 bytes in 1 blocks are still reachable in loss record 3 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x438D77: s_bin_dup (in /home/valgrind/test/main)
==19422==    by 0x438ED1: find_tmp_type (in /home/valgrind/test/main)
==19422==    by 0x438FF9: get_type (in /home/valgrind/test/main)
==19422==    by 0x43A06C: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 16 bytes in 1 blocks are still reachable in loss record 4 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x439810: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 22 bytes in 3 blocks are still reachable in loss record 5 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x438D77: s_bin_dup (in /home/valgrind/test/main)
==19422==    by 0x438ED1: find_tmp_type (in /home/valgrind/test/main)
==19422==    by 0x438FF9: get_type (in /home/valgrind/test/main)
==19422==    by 0x4393F8: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 31 bytes in 5 blocks are still reachable in loss record 6 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x438D77: s_bin_dup (in /home/valgrind/test/main)
==19422==    by 0x4398E2: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 32 bytes in 1 blocks are still reachable in loss record 7 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x4430EA: erl_init_eterm_alloc (in /home/valgrind/test/main)
==19422==    by 0x42E0E8: erl_init (in /home/valgrind/test/main)
==19422==    by 0x41A8E1: confd_init_vsn_sz (in /home/valgrind/test/main)
==19422==    by 0x4024CA: main (in /home/valgrind/test/main)
==19422==
==19422== 40 bytes in 1 blocks are still reachable in loss record 8 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x44267A: ei_m_create (in /home/valgrind/test/main)
==19422==    by 0x4431E9: ei_mutex_create (in /home/valgrind/test/main)
==19422==    by 0x443115: erl_init_eterm_alloc (in /home/valgrind/test/main)
==19422==    by 0x42E0E8: erl_init (in /home/valgrind/test/main)
==19422==    by 0x41A8E1: confd_init_vsn_sz (in /home/valgrind/test/main)
==19422==    by 0x4024CA: main (in /home/valgrind/test/main)
==19422==
==19422== 48 bytes in 1 blocks are still reachable in loss record 9 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x434356: s_calloc (in /home/valgrind/test/main)
==19422==    by 0x438EF7: find_tmp_type (in /home/valgrind/test/main)
==19422==    by 0x438FF9: get_type (in /home/valgrind/test/main)
==19422==    by 0x43A06C: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 48 bytes in 3 blocks are still reachable in loss record 10 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x4396EB: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 61 bytes in 8 blocks are still reachable in loss record 11 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x438D77: s_bin_dup (in /home/valgrind/test/main)
==19422==    by 0x438ED1: find_tmp_type (in /home/valgrind/test/main)
==19422==    by 0x438FF9: get_type (in /home/valgrind/test/main)
==19422==    by 0x439D70: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 79 bytes in 14 blocks are still reachable in loss record 12 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x438D77: s_bin_dup (in /home/valgrind/test/main)
==19422==    by 0x43A653: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 80 bytes in 1 blocks are still reachable in loss record 13 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x43281F: _confd_create_hashtable_mallf (in /home/valgrind/test/main)
==19422==    by 0x43AC16: load_hash_db (in /home/valgrind/test/main)
==19422==    by 0x43AF61: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 80 bytes in 1 blocks are still reachable in loss record 14 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x43281F: _confd_create_hashtable_mallf (in /home/valgrind/test/main)
==19422==    by 0x43AC5C: load_hash_db (in /home/valgrind/test/main)
==19422==    by 0x43AF61: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 87 bytes in 5 blocks are still reachable in loss record 15 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x438D77: s_bin_dup (in /home/valgrind/test/main)
==19422==    by 0x438ED1: find_tmp_type (in /home/valgrind/test/main)
==19422==    by 0x438FF9: get_type (in /home/valgrind/test/main)
==19422==    by 0x439F30: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 88 bytes in 1 blocks are still reachable in loss record 16 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x4430BE: erl_eterm_alloc (in /home/valgrind/test/main)
==19422==    by 0x42F1A7: erl_alloc_eterm (in /home/valgrind/test/main)
==19422==    by 0x430CE4: erl_decode_it (in /home/valgrind/test/main)
==19422==    by 0x431660: erl_decode (in /home/valgrind/test/main)
==19422==    by 0x40EB74: term_read (in /home/valgrind/test/main)
==19422==    by 0x43A42B: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 88 bytes in 1 blocks are still reachable in loss record 17 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x4430BE: erl_eterm_alloc (in /home/valgrind/test/main)
==19422==    by 0x42F1A7: erl_alloc_eterm (in /home/valgrind/test/main)
==19422==    by 0x430CE4: erl_decode_it (in /home/valgrind/test/main)
==19422==    by 0x430FBB: erl_decode_it (in /home/valgrind/test/main)
==19422==    by 0x431660: erl_decode (in /home/valgrind/test/main)
==19422==    by 0x40EB74: term_read (in /home/valgrind/test/main)
==19422==    by 0x439335: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 94 bytes in 15 blocks are still reachable in loss record 18 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x43A23B: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 120 bytes in 1 blocks are still reachable in loss record 19 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x439877: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 120 bytes in 15 blocks are still reachable in loss record 20 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x43A033: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 132 bytes in 12 blocks are still reachable in loss record 21 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x438D77: s_bin_dup (in /home/valgrind/test/main)
==19422==    by 0x43A6CE: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 144 bytes in 3 blocks are still reachable in loss record 22 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x434356: s_calloc (in /home/valgrind/test/main)
==19422==    by 0x438EF7: find_tmp_type (in /home/valgrind/test/main)
==19422==    by 0x438FF9: get_type (in /home/valgrind/test/main)
==19422==    by 0x4393F8: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 240 bytes in 5 blocks are still reachable in loss record 23 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x434356: s_calloc (in /home/valgrind/test/main)
==19422==    by 0x438EF7: find_tmp_type (in /home/valgrind/test/main)
==19422==    by 0x438FF9: get_type (in /home/valgrind/test/main)
==19422==    by 0x439F30: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 240 bytes in 15 blocks are still reachable in loss record 24 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x439EA9: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 240 bytes in 15 blocks are still reachable in loss record 25 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x439EDA: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 240 bytes in 15 blocks are still reachable in loss record 26 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x43A204: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 254 bytes in 21 blocks are still reachable in loss record 27 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x411C7F: bufdup (in /home/valgrind/test/main)
==19422==    by 0x412637: confd_value_dup_to_mallf (in /home/valgrind/test/main)
==19422==    by 0x43A392: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 264 bytes in 3 blocks are still reachable in loss record 28 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x4430BE: erl_eterm_alloc (in /home/valgrind/test/main)
==19422==    by 0x42F1A7: erl_alloc_eterm (in /home/valgrind/test/main)
==19422==    by 0x430CE4: erl_decode_it (in /home/valgrind/test/main)
==19422==    by 0x430D25: erl_decode_it (in /home/valgrind/test/main)
==19422==    by 0x430FBB: erl_decode_it (in /home/valgrind/test/main)
==19422==    by 0x431660: erl_decode (in /home/valgrind/test/main)
==19422==    by 0x40EB74: term_read (in /home/valgrind/test/main)
==19422==    by 0x439335: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==
==19422== 296 bytes in 36 blocks are still reachable in loss record 29 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x439A6C: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 324 bytes in 24 blocks are still reachable in loss record 30 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x438D77: s_bin_dup (in /home/valgrind/test/main)
==19422==    by 0x439755: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 384 bytes in 8 blocks are still reachable in loss record 31 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x434356: s_calloc (in /home/valgrind/test/main)
==19422==    by 0x438EF7: find_tmp_type (in /home/valgrind/test/main)
==19422==    by 0x438FF9: get_type (in /home/valgrind/test/main)
==19422==    by 0x439D70: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 440 bytes in 5 blocks are still reachable in loss record 32 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x4430BE: erl_eterm_alloc (in /home/valgrind/test/main)
==19422==    by 0x42F1A7: erl_alloc_eterm (in /home/valgrind/test/main)
==19422==    by 0x430CE4: erl_decode_it (in /home/valgrind/test/main)
==19422==    by 0x430FBB: erl_decode_it (in /home/valgrind/test/main)
==19422==    by 0x431660: erl_decode (in /home/valgrind/test/main)
==19422==    by 0x40EB74: term_read (in /home/valgrind/test/main)
==19422==    by 0x43A42B: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 448 bytes in 1 blocks are still reachable in loss record 33 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x413CB3: confd_register_schemas (in /home/valgrind/test/main)
==19422==    by 0x43A87E: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 520 bytes in 1 blocks are still reachable in loss record 34 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x4A06167: realloc (vg_replace_malloc.c:525)
==19422==    by 0x41C7EC: get_lasterr (in /home/valgrind/test/main)
==19422==    by 0x41C84A: confd_lasterr (in /home/valgrind/test/main)
==19422==    by 0x41C8DD: clr_confd_err (in /home/valgrind/test/main)
==19422==    by 0x40C257: confd_do_connect (in /home/valgrind/test/main)
==19422==    by 0x4414EA: maapi_connect (in /home/valgrind/test/main)
==19422==    by 0x41186D: get_maapi_sock (in /home/valgrind/test/main)
==19422==    by 0x41196E: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 568 bytes in 14 blocks are still reachable in loss record 35 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x438D77: s_bin_dup (in /home/valgrind/test/main)
==19422==    by 0x43A638: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 576 bytes in 3 blocks are still reachable in loss record 36 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x439722: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 736 bytes in 23 blocks are still reachable in loss record 37 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x43A18D: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 840 bytes in 15 blocks are still reachable in loss record 38 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x434356: s_calloc (in /home/valgrind/test/main)
==19422==    by 0x439BEF: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 896 bytes in 1 blocks are still reachable in loss record 39 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x43A749: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 1,296 bytes in 81 blocks are still reachable in loss record 40 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x43A0B6: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 1,600 bytes in 20 blocks are still reachable in loss record 41 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x43A2B5: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 1,903 bytes in 329 blocks are still reachable in loss record 42 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x438D77: s_bin_dup (in /home/valgrind/test/main)
==19422==    by 0x438ED1: find_tmp_type (in /home/valgrind/test/main)
==19422==    by 0x43938F: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==
==19422== 1,968 bytes in 41 blocks are still reachable in loss record 43 of 59
==19422==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19422==    by 0x40C604: confd_malloc (in /home/valgrind/test/main)
==19422==    by 0x434356: s_calloc (in /home/valgrind/test/main)
==19422==    by 0x439AFA: load_one_ns (in /home/valgrind/test/main)
==19422==    by 0x43A4EF: load_many_ns (in /home/valgrind/test/main)
==19422==    by 0x43AF56: maapi_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x41197D: confd_load_schemas (in /home/valgrind/test/main)
==19422==    by 0x402507: main (in /home/valgrind/test/main)
==19422==

libconfd_no_fix_alloc

==19437== Memcheck, a memory error detector
==19437== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==19437== Using Valgrind-3.6.0 and LibVEX; rerun with -h for copyright info
==19437== Command: ./main
==19437==
TRACE Connected (maapi) to ConfD
TRACE MAAPI_LOAD_ALL_NS
TRACE MAAPI_LOAD_HASH_DB
TRACE Connected (cdb) to ConfD
finished
==19437==
==19437== HEAP SUMMARY:
==19437==     in use at exit: 178,802 bytes in 3,937 blocks
==19437==   total heap usage: 32,933 allocs, 28,996 frees, 1,967,677 bytes allocated
==19437==
==19437== 4 bytes in 1 blocks are still reachable in loss record 1 of 52
==19437==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19437==    by 0x41DB79: confd_errno_location (confd_lib.c:167)
==19437==    by 0x41DBA5: clr_confd_err (confd_lib.c:243)
==19437==    by 0x40C79C: confd_do_connect (confd_internal.c:803)
==19437==    by 0x4446CA: maapi_connect (maapi.c:39)
==19437==    by 0x4120DE: get_maapi_sock (confd_lib.c:10162)
==19437==    by 0x4121DE: confd_load_schemas (confd_lib.c:10171)
==19437==    by 0x402507: main (in /home/valgrind/test/main)
==19437==
==19437== 8 bytes in 1 blocks are still reachable in loss record 2 of 52
==19437==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19437==    by 0x4467FA: ei_mutex_create (ei_locking.c:61)
==19437==    by 0x446725: erl_init_eterm_alloc (erl_fix_alloc.c:74)
==19437==    by 0x430908: erl_init (erl_eterm.c:63)
==19437==    by 0x41B8FF: confd_init_vsn_sz (confd_lib.c:1899)
==19437==    by 0x4024CA: main (in /home/valgrind/test/main)
==19437==
==19437== 15 bytes in 1 blocks are still reachable in loss record 3 of 52
==19437==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19437==    by 0x40CB44: confd_malloc (confd_internal.c:59)
==19437==    by 0x43B932: s_bin_dup (maapi.c:3800)
==19437==    by 0x43BA96: find_tmp_type (maapi.c:4025)
==19437==    by 0x43BBC3: get_type (maapi.c:4066)
==19437==    by 0x43D102: load_many_ns (maapi.c:4388)
==19437==    by 0x43DEE6: maapi_load_schemas (maapi.c:4859)
==19437==    by 0x4121ED: confd_load_schemas (confd_lib.c:10173)
==19437==    by 0x402507: main (in /home/valgrind/test/main)
==19437==
==19437== 16 bytes in 1 blocks are still reachable in loss record 4 of 52
==19437==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19437==    by 0x40CB44: confd_malloc (confd_internal.c:59)
==19437==    by 0x43CE30: load_many_ns (maapi.c:4297)
==19437==    by 0x43DEE6: maapi_load_schemas (maapi.c:4859)
==19437==    by 0x4121ED: confd_load_schemas (confd_lib.c:10173)
==19437==    by 0x402507: main (in /home/valgrind/test/main)
==19437==
==19437== 22 bytes in 3 blocks are still reachable in loss record 5 of 52
==19437==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19437==    by 0x40CB44: confd_malloc (confd_internal.c:59)
==19437==    by 0x43B932: s_bin_dup (maapi.c:3800)
==19437==    by 0x43BA96: find_tmp_type (maapi.c:4025)
==19437==    by 0x43BBC3: get_type (maapi.c:4066)
==19437==    by 0x43C404: load_many_ns (maapi.c:4218)
==19437==    by 0x43DEE6: maapi_load_schemas (maapi.c:4859)
==19437==    by 0x4121ED: confd_load_schemas (confd_lib.c:10173)
==19437==    by 0x402507: main (in /home/valgrind/test/main)
==19437==
==19437== 31 bytes in 5 blocks are still reachable in loss record 6 of 52
==19437==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19437==    by 0x40CB44: confd_malloc (confd_internal.c:59)
==19437==    by 0x43B932: s_bin_dup (maapi.c:3800)
==19437==    by 0x43CF17: load_many_ns (maapi.c:4310)
==19437==    by 0x43DEE6: maapi_load_schemas (maapi.c:4859)
==19437==    by 0x4121ED: confd_load_schemas (confd_lib.c:10173)
==19437==    by 0x402507: main (in /home/valgrind/test/main)
==19437==
==19437== 32 bytes in 1 blocks are still reachable in loss record 7 of 52
==19437==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19437==    by 0x4466FA: erl_init_eterm_alloc (erl_fix_alloc.c:67)
==19437==    by 0x430908: erl_init (erl_eterm.c:63)
==19437==    by 0x41B8FF: confd_init_vsn_sz (confd_lib.c:1899)
==19437==    by 0x4024CA: main (in /home/valgrind/test/main)
==19437==
==19437== 40 bytes in 1 blocks are still reachable in loss record 8 of 52
==19437==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19437==    by 0x445CAA: ei_m_create (ei_pthreads.c:116)
==19437==    by 0x446807: ei_mutex_create (ei_locking.c:72)
==19437==    by 0x446725: erl_init_eterm_alloc (erl_fix_alloc.c:74)
==19437==    by 0x430908: erl_init (erl_eterm.c:63)
==19437==    by 0x41B8FF: confd_init_vsn_sz (confd_lib.c:1899)
==19437==    by 0x4024CA: main (in /home/valgrind/test/main)
==19437==
==19437== 48 bytes in 1 blocks are still reachable in loss record 9 of 52
==19437==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19437==    by 0x40CB44: confd_malloc (confd_internal.c:59)
==19437==    by 0x436CB6: s_calloc (maapi.c:3775)
==19437==    by 0x43BABC: find_tmp_type (maapi.c:4027)
==19437==    by 0x43BBC3: get_type (maapi.c:4066)
==19437==    by 0x43D102: load_many_ns (maapi.c:4388)
==19437==    by 0x43DEE6: maapi_load_schemas (maapi.c:4859)
==19437==    by 0x4121ED: confd_load_schemas (confd_lib.c:10173)
==19437==    by 0x402507: main (in /home/valgrind/test/main)
==19437==
==19437== 48 bytes in 3 blocks are still reachable in loss record 10 of 52
==19437==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19437==    by 0x40CB44: confd_malloc (confd_internal.c:59)
==19437==    by 0x43CC48: load_many_ns (maapi.c:4261)
==19437==    by 0x43DEE6: maapi_load_schemas (maapi.c:4859)
==19437==    by 0x4121ED: confd_load_schemas (confd_lib.c:10173)
==19437==    by 0x402507: main (in /home/valgrind/test/main)
==19437==
==19437== 61 bytes in 8 blocks are still reachable in loss record 11 of 52
==19437==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==19437==    by 0x40CB44: confd_malloc (confd_internal.c:59)
==19437==    by 0x43B932: s_bin_dup (maapi.c:3800)
==19437==    by 0x43BA96: find_tmp_type (maapi.c:4025)
==19437==    by 0x43BBC3: get_type (maapi.c:4066)
==19437==    by 0x43C97F: load_many_ns (maapi.c:4655)
==19437==    by 0x43DEE6: maapi_load_schemas (maapi.c:4859)
==19437==    by 0x4121ED: confd_load_schemas (confd_lib.c:10173)
==19437==    by 0x402507: main (in /home/valgrind/test/main)

There are some allocations done by condf_init() and condf_load_schemas()/maapi_load_schemas() etc. for which there is no “free” counterpart. This memory is kept under control by the libconfd library.

So there is no memory leak in your example application since all memory not free():ed are still reachable, i.e. “semi permanent” allocations.

E.g. mutex, callpoint registrations, active user session etc. that isn’t free():ed at exit() since there is no point in doing that. The libconfd library code reuses the memory or free and allocate the same amount again.

1 Like

Is there a way to differentiate between this still reachable bytes you’re talking about, and the following scenario:

A lib that continuously allocating memory without free()'ing?

Here is another explanation on the type of “still reachable” blocks ConfD use that I Googled:

In general, there is no need to worry about “still reachable” blocks. They don’t pose the sort of problem that true memory leaks can cause. For instance, there is normally no potential for heap exhaustion from “still reachable” blocks. This is because these blocks are usually one-time allocations, references to which are kept throughout the duration of the process’s lifetime. While you could go through and ensure that your program frees all allocated memory, there is usually no practical benefit from doing so since the operating system will reclaim all of the process’s memory after the process terminates, anyway. Contrast this with true memory leaks which, if left unfixed, could cause a process to run out of memory if left running long enough, or will simply cause a process to consume far more memory than is necessary.

The complete reply can be found here:

1 Like