From: Warren Young Date: October 14 2009 10:57am Subject: Re: Connection Object throws exception List-Archive: http://lists.mysql.com/plusplus/8727 Message-Id: <5778241F-7DBA-4C2B-AA0A-6F1237309470@etr-usa.com> MIME-Version: 1.0 (Apple Message framework v1076) Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit On Oct 13, 2009, at 10:48 PM, B Singh wrote: > Is it bad idea to have connection object in heap ? No, I think most real programs using MySQL++ do it that way. It's on the stack in the examples just to keep them simple. > I see all samples are using stack variable for connection and only > heap for > multistatementoption. Actually, the cpool example keeps its Connection objects on the heap, too. It's not obvious because we use the default creation mechanism in ConnectionPool::create(), rather than provide our own. > delete m_pcommonMultiStOption; There's your bug. MySQL++ owns the option objects after you pass them to Connection::set_option(). If you delete them yourself, you get a double-delete, which is what's crashing your program.