Uploaded image for project: 'MariaDB Connector/C'
  1. MariaDB Connector/C
  2. CONC-173

Memory leak mysql_real_connect() when linking with mariadb_config --libs

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 3.0.0
    • 3.0.0
    • None
    • None

    Description

      I try to use lgpl version of mysql c connector. When I link test program using:
      mariadb_config --libs and mariadb_config --cflags, then I got memory leak.
      When I link the same program using mysql_config --libs and mysql_config --cflags,
      then there is no memory leak.
      Is it a library bug or there is a bug in my test program?
      My test function:

         for(;;) {
                      MYSQL mysql;
                      int arg;
                      mysql_init(&mysql);
                      mysql_options(&mysql, MYSQL_READ_DEFAULT_GROUP, "client");
                      mysql_options(&mysql, MYSQL_OPT_COMPRESS, 0);
                      mysql_options(&mysql, MYSQL_OPT_NAMED_PIPE, 0);
                      arg = MYSQL_PROTOCOL_SOCKET;
                      mysql_options(&mysql, MYSQL_OPT_PROTOCOL, &arg);
                      if(!mysql_real_connect(&mysql, "localhost", DBUSER, DBPASS, DBNAME,
      0, 0, 0))  {
                              fprintf(stderr, "Failed to connect to database: Error: %s\n", mysql_error(&mysql));
                              return 1;
                      }
                      mysql_close(&mysql);
              }
              return 0;
      

      I monitor memory usage with:

      while true; do ps -o rss $PID; sleep 1; done
      

      Without mysql_real_connect() there is no memory leak.

      Attachments

        Activity

          People

            georg Georg Richter
            jsiebert Jarosław Siebert
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.