Giter Club home page Giter Club logo

Comments (15)

rbock avatar rbock commented on July 21, 2024 1

I am sure this will help. Will look into it asap. Thanks for the reports!!

from sqlpp11-connector-mysql.

ociotec avatar ociotec commented on July 21, 2024

By the way, credits: Valgrind detected this issue.

from sqlpp11-connector-mysql.

rbock avatar rbock commented on July 21, 2024

Thanks! I believe I fixed this with the commit I just pushed to develop.

from sqlpp11-connector-mysql.

ociotec avatar ociotec commented on July 21, 2024

@rbock sorry but now I have 2 possible memory leaks and 1 definite memory leak report from valgrind (before I only had the 2 possible memory leaks).

I'm running valgrind with these options:

valgrind --leak-check=full --error-limit=no --show-leak-kinds=definite,indirect,possible \
         --log-file=reports/valgrind.log \
         --xml=yes --xml-file=reports/valgrind.xml

I've atteched the XML report valgrind.xml.tar.gz (I don't know why but plain text report is empty...).

from sqlpp11-connector-mysql.

ociotec avatar ociotec commented on July 21, 2024

I was able to generate the valgrid plain text log file (you can only generate plain text or XML, but not both at the same time...): valgrind.log

I hope this could help you... thanks! 👍

from sqlpp11-connector-mysql.

rbock avatar rbock commented on July 21, 2024

Thanks! This helped indeed. A new version is on develop.

I fixed a leak and added an raii struct for mysql_library_init/mysql_library_end. valgrind seems happy in the few tests I ran by now.

from sqlpp11-connector-mysql.

ociotec avatar ociotec commented on July 21, 2024

@rbock I will try to test it asap. Thanks!

from sqlpp11-connector-mysql.

ociotec avatar ociotec commented on July 21, 2024

@rbock now we have the 2 original possible memory leaks detected by Valgrind (valgrind.log).

I think problem could fix it adding delete _handle before throwing the exceptions:

    connection::connection(const std::shared_ptr<connection_config>& config)
        : _handle(new detail::connection_handle_t(config))
    {
      if (mysql_set_character_set(_handle->mysql.get(), _handle->config->charset.c_str()))
      {
        delete _handle;
        throw sqlpp::exception("MySQL error: can't set character set " + _handle->config->charset);
      }

      if (mysql_select_db(_handle->mysql.get(), _handle->config->database.c_str()))
      {
        delete _handle;
        throw sqlpp::exception("MySQL error: can't select database '" + _handle->config->database + "'");
      }
}

Maybe it's good to take a look to mysql_set_character_set & mysql_select_db to check if they also throw any exception...

from sqlpp11-connector-mysql.

rbock avatar rbock commented on July 21, 2024

Are you sure you are using the latest version? If so, which program are you running with valgrind?

Deleting _handle does not really help since it is a unique_ptr and will clean itself up.

There was a problem in case new MYSQL failed, but I just pushed something that I guess will fix that, too.

For ./tests/Sqlpp11MySQLSampleTest valgrind tells me:

All heap blocks were freed -- no leaks are possible

Hope this is it now. In any case, thanks for pushing!

from sqlpp11-connector-mysql.

ociotec avatar ociotec commented on July 21, 2024

Run Valgrind like this (include possible leak kind):

valgrind --leak-check=full --error-limit=no --show-leak-kinds=definite,indirect,possible \
         --log-file=valgrind.log <program-to-run>

from sqlpp11-connector-mysql.

ociotec avatar ociotec commented on July 21, 2024

@rbock I think I correctly updated develop version due the fact the 1 definite leak error dissapeared with your latest version.

from sqlpp11-connector-mysql.

rbock avatar rbock commented on July 21, 2024

Sure, that's what I do. And it says no leaks are possible. This is why I would like to know which program you are running. Can you post the code of a minimal program that shows the leak?

Have you tried with the code I pushed today (like 30mins ago)?

from sqlpp11-connector-mysql.

rbock avatar rbock commented on July 21, 2024

Also, can you please make sure that you are using either the

const auto library_raii = sqlpp::mysql::scoped_library_initializer_t{};

or

::sqlpp::mysql::global_library_init();

(See tests)

These make sure to initialize the mysql library and free its resources when you are done.

Thanks!

from sqlpp11-connector-mysql.

ociotec avatar ociotec commented on July 21, 2024

@rbock finally, with latest changes + calling sqlpp::mysql::global_library_init(); we achieved a clean Valgrind report (valgrind.log).

Thanks a lot!

from sqlpp11-connector-mysql.

rbock avatar rbock commented on July 21, 2024

Awesome!

Thanks for your help :-)

from sqlpp11-connector-mysql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.