I woke up about 2am this morning with a hankering to fix a memory leak... strange.

Sqlite 3.2.7 had been leaking memory like a sieve. I guessed (correctly) that there was no problem with the library, and that the problem was with the C++ wrapper that I am using: CppSQLite3. Actually, the problem wasn't directly caused by any flaw in CppSQLite3. The sqlite_finalize function is called from the deconstructor of the CppSQLite3Statement object. However, when compiled with GCC 4.0.0. (with the /O2 optimization option) this function had no effect causing sqlite3 to leak memory. I made a one line addition to my code base, explicitly calling CppSQLite3Statement::finalize(), which in turn calls sqlite_finalize(), and the leak went away.

The end result for me is a major major improvement in my program's stability. There is still a bit of a leak somewhere - I would guess in zlib, but I haven't tracked it down all the way yet.

 

Add to My Yahoo!

Add to Google

Subscribe with Bloglines

Austin Gilbert/Male/26-30. Lives in United States/Oklahoma/Tulsa/Midtown, speaks English. Spends 40% of daytime online. Uses a Fast (128k-512k) connection. And likes computer science/photography.
This is my blogchalk: United States, Oklahoma, Tulsa, Midtown, English, Austin Gilbert, Male, 26-30, computer science, photography.

CppSQLite3Statement + GCC 4.0.0 + /O2
2005/10/16