Thank you for your response, Ulrich.
utelle wrote:
Which version of SQLite do you use? Do you use a precompiled version of SQlite or do you compile it yourself? In the latter case: which #defines do you use? Which modifications did you apply to the code of the minimal sample?
I took all the source code from wxSqlite3-3.0.0.1 and build a new MSVC project for the 'minimal' example, i.e. minimal.cpp, minmal.rc as well as the code for wxsqlite3.cpp and all of sqlite3.c & .h.
None of the 'minimal' code was modified.
In sqlite3.c I inserted:
at the very top:
Code: Select all
---------------------------
#ifndef SQLITE_API
# define SQLITE_API
#endif
// start of my code +++++++++++++++++
if defined( _MSC_VER )
//-------------------------------------------------------------------
// this statement NEEDS to go BEFORE all headers
// see other part at line 10626 ++
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
// ------------------------------------------------------------------
#endif
// end of my code +++++++++++++++++++++++
/************** Begin file sqliteInt.h ***************************************/
---------------------------
near 12154:
Code: Select all
#endif /* _SQLITEINT_H_ */
/************** End of sqliteInt.h *******************************************/
// start of my code ++++++++++++++++++++++++++++++
#if defined( _MSC_VER )
// this block needs to go AFTER all headers
#include <crtdbg.h>
#ifdef _DEBUG
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define new DEBUG_NEW
#endif
#endif
// end of my code ++++++++++++++++++++++++++++
/************** Begin file global.c ******************************************/
As far as #defines, I currently have defined:
Code: Select all
WIN32
WXUSINGDLL
_UNICODE
__WXDEBUG__
__WXMSW__
_CONSOLE
_DEBUG
I understand there are some sqlite specific #defines, but at present none are defined.
If there are any which ought to be defined, please let me know and I will set them up.
To have as much control over what is actually in the executable, I have also compiled it with static linking of all of the application's code, other then the wxWidgets 2.8.10 DLLs.
utelle wrote:... as far as I know the code of wxSQLite3 and SQLite exposes no memory leaks. Before I release a new version of wxSQLite3 I usually check at least the minimal sample and up to now I didn't detect memory leaks. I use wxSQLite3 and SQLite myself for many years in different projects and didn't experience memory leaks, neither in wxSQLite3 nor in SQLite.
I take this then that 'minimal' is intended to clean up after itself and ought to have no (known)memory leaks.
utelle wrote:I use VC++ 2008 and VC++ 2010 for development and I usually also test with gcc, so I don't think it's specific to the compiler.
That is encouraging, at least we have a (more or less) common compile environment
utelle wrote:A problem in debugging SQLite is that the SQLite amalgamation source file has too many lines for the VC++ debugger. For debugging SQLite one would have to divide the sources into smaller pieces.
I have suspected as much a number of times
utelle wrote:
But SQLite is very well tested. If you experience memory leaks it's probably due to your application's code not finalizing SQLite statements and/or other SQLite data structures.
That is why I used the minimal example as 'application'. It removes all of my code and a lot of wxWidgets code as well.
Widgets wrote:And, FWIW, as far as I have checked, all the leaks originate at this same line in the sqlite3.c code
This is not surprising as SQLite encapsulates memory allocation in a small function which is located around that very line in the SQLite amalgamation source code.
Regards,
Ulrich[/quote]