Page 5 of 5 FirstFirst ... 345
Results 41 to 44 of 44

Thread: Memory leaks

  1. #41
    Join Date
    Nov 2009
    Beans
    1,081

    Re: Memory leaks

    Have you checked the mysql++ documentation? It's answered there.

    http://tangentsoft.net/mysql++/doc/h...n/threads.html

  2. #42
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,239
    Distro
    Kubuntu

    Re: Memory leaks

    Quote Originally Posted by hosseinyounesi View Post
    The code I posted is my real code:
    You should guard against unforeseen failures. For example:
    Code:
       try
       {
          mysqlpp::Connection       dbconn(database.c_str(), host.c_str(), user.c_str(), password.c_str());
          mysqlpp::Query            query = dbconn.query();
          mysqlpp::StoreQueryResult result = query.store(thequery.c_str());
    
          if (result)
          {
             doSomethingWithResult(result);
    
             while (query.more_results())
             {
                doSomethingWithResult(query.store_next());
             }
          }
          else
          {
             // some queries do not return results; yet by being here
             // we know that the query was successful.
          }
       }
       catch (std::exception& e)
       {
          std::cerr << "Caught exception: " << e.what() << std::endl;
       }
    Quote Originally Posted by hosseinyounesi View Post
    is mysqlpp thread-safe?
    The link provided by Some Penguin offers good advice on this subject.

  3. #43
    Join Date
    Jul 2008
    Beans
    95

    Re: Memory leaks

    I replaced libmysqlclient.so with libmysqlclient_r.so and now it's working fine! No change in mysqlpp code or my code in using mysqlpp. What's the difference between 2 these files?!!!

    Thanks b4

  4. #44
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,239
    Distro
    Kubuntu

    Re: Memory leaks

    Quote Originally Posted by hosseinyounesi View Post
    I replaced libmysqlclient.so with libmysqlclient_r.so and now it's working fine! No change in mysqlpp code or my code in using mysqlpp. What's the difference between 2 these files?!!!

    Thanks b4
    It seems that you did not read the documentation carefully enough.
    If you use a binary distribution of MySQL on Unixy systems, you usually get two different versions of the MySQL C API library, one with thread support and one without. These are typically called libmysqlclient and libmysqlclient_r, the latter being the thread-safe one. (The “_r” means reentrant.)
    Did you not read about the ConnectionPool? You had better be using that too, since from what you described earlier, you have lots of connections in many different threads.

Page 5 of 5 FirstFirst ... 345

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •