Uploaded image for project: 'Couchbase C client library libcouchbase'
  1. Couchbase C client library libcouchbase
  2. CCBC-791

Memory leak after destroying connection

    XMLWordPrintable

Details

    • Task
    • Resolution: Fixed
    • Minor
    • 2.7.6
    • 2.7.4, 2.7.5
    • library
    • None
    • CentOS 6.8, libcouchbase 2.7.4, libevent-2.0.21

    Description

      As of libcouchbase 2.7.4 (perhaps started in an earlier version > 2.7.0), there is memory allocated by lcb_create() which is not freed upon lcb_destroy().

      The exact same application code did not show the leak on libcouchbase 2.4.7 and 2.7.0. It does on 2.7.4 and latest git master.

      It can be triggered by the example/libeventdirect/main.c example, after correcting the destruction of the connection:

      — main.c.org 2017-05-18 14:57:53.111670506 +0200
      +++ main.c 2017-05-18 14:46:30.682121741 +0200
      @@ -143,7 +143,8 @@
      event_base_loop(evbase, 0);

      /* Cleanup */

      • event_base_free(evbase);
        lcb_destroy(instance);
        + lcb_destroy_io_ops(ioops);
        + event_base_free(evbase);
        exit(EXIT_SUCCESS);
        }

       

      Valgrind output:

      ==1842== 80 bytes in 1 blocks are definitely lost in loss record 2 of 2
      ==1842== at 0x4A095A5: operator new(unsigned long) (vg_replace_malloc.c:333)
      ==1842== by 0x4C55BF1: lcb_create (instance.cc:426)
      ==1842== by 0x400FDE: create_libcouchbase_handle (in /home/rgr/src/couchbase/libcouchbase/example/libeventdirect/main)
      ==1842== by 0x4010E8: main (in /home/rgr/src/couchbase/libcouchbase/example/libeventdirect/main)

      Attachments

        For Gerrit Dashboard: CCBC-791
        # Subject Branch Project Status CR V

        Activity

          People

            mnunberg Mark Nunberg (Inactive)
            penacho Robert Groenenberg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty