Large Memory leaks when using SQLite
I am using SQLite in Visual C++, MFC. I sqlite3_finalize every statement prepared by sqlit开发者_如何学Goe3_prepare. When closing application I close db connection.
Where could be a problem? Thanks
sqlite3 does occasionally allocate strings that should be freed by the user, such as the error message from an sqlite3_exec() call. Search this page
http://www.sqlite.org/capi3ref.html
for the sqlite3_free
string and you will find several cases like this. Are you certain that you are handling these cases in your code correctly?
From my experience sqlite3 does not generally leak memory on its own, although its memory use does increase very slowly up to a certain point as it caches some information and its internal memory allocator reserves some memory blocks. How did you detect the memory leak and how did you determine sqlite3 as the cause?
Have you used the MSVC memory leak debugging facilities? Visual Studio provides a source-code based memory debugging facility:
http://msdn.microsoft.com/en-us/library/x98tx3cf%28v=VS.100%29.aspx
It should help you pinpoint the cause of any memory leaks.
Based on answer above , I did find from sqlite documentation that if there is any error returned by sqlite in any statement executed through sqlite3_exec than sqlite allocates the memory required for error message and it is responsibility of application to free that memory .
精彩评论