diff options
author | danielk1977 <danielk1977@noemail.net> | 2008-03-28 07:42:53 +0000 |
---|---|---|
committer | danielk1977 <danielk1977@noemail.net> | 2008-03-28 07:42:53 +0000 |
commit | dbdc4d49cbf81aaadfa43f9bb84582f467473aa0 (patch) | |
tree | 2eeab02a79f54e9960173b71bfd217e1bc1e96b9 /src/test_malloc.c | |
parent | 19db935225bc66eafbc830e3a76262a0d68d870a (diff) | |
download | sqlite-dbdc4d49cbf81aaadfa43f9bb84582f467473aa0.tar.gz sqlite-dbdc4d49cbf81aaadfa43f9bb84582f467473aa0.zip |
If memory is leaked when running a test script with the --malloctrace option, write out a file called leaks.sql in the same format as mallocs.sql containing th e leaked applications. The same tools can then be used to examine the stack traces associated with leaked allocations. (CVS 4926)
FossilOrigin-Name: f1b97ed93183378ff56b4fe7ae8ea269c24092fc
Diffstat (limited to 'src/test_malloc.c')
-rw-r--r-- | src/test_malloc.c | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/src/test_malloc.c b/src/test_malloc.c index 3595a0651..09b87fcaa 100644 --- a/src/test_malloc.c +++ b/src/test_malloc.c @@ -13,7 +13,7 @@ ** This file contains code used to implement test interfaces to the ** memory allocation subsystem. ** -** $Id: test_malloc.c,v 1.19 2008/03/25 09:47:35 danielk1977 Exp $ +** $Id: test_malloc.c,v 1.20 2008/03/28 07:42:54 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -546,6 +546,21 @@ static void test_memdebug_callback(int nByte, int nFrame, void **aFrame){ } } +static int test_memdebug_log_clear(){ + Tcl_HashSearch search; + Tcl_HashEntry *pEntry; + for( + pEntry=Tcl_FirstHashEntry(&aMallocLog, &search); + pEntry; + pEntry=Tcl_NextHashEntry(&search) + ){ + MallocLog *pLog = (MallocLog *)Tcl_GetHashValue(pEntry); + Tcl_Free((char *)pLog); + } + Tcl_DeleteHashTable(&aMallocLog); + Tcl_InitHashTable(&aMallocLog, MALLOC_LOG_FRAMES); +} + static int test_memdebug_log( void * clientData, Tcl_Interp *interp, @@ -555,8 +570,10 @@ static int test_memdebug_log( static int isInit = 0; int iSub; - enum MB_enum { MB_LOG_START, MB_LOG_STOP, MB_LOG_DUMP, MB_LOG_CLEAR }; - static const char *MB_strs[] = { "start", "stop", "dump", "clear" }; + static const char *MB_strs[] = { "start", "stop", "dump", "clear", "sync" }; + enum MB_enum { + MB_LOG_START, MB_LOG_STOP, MB_LOG_DUMP, MB_LOG_CLEAR, MB_LOG_SYNC + }; if( !isInit ){ #ifdef SQLITE_MEMDEBUG @@ -614,18 +631,16 @@ static int test_memdebug_log( break; } case MB_LOG_CLEAR: { - Tcl_HashSearch search; - Tcl_HashEntry *pEntry; - for( - pEntry=Tcl_FirstHashEntry(&aMallocLog, &search); - pEntry; - pEntry=Tcl_NextHashEntry(&search) - ){ - MallocLog *pLog = (MallocLog *)Tcl_GetHashValue(pEntry); - Tcl_Free((char *)pLog); - } - Tcl_DeleteHashTable(&aMallocLog); - Tcl_InitHashTable(&aMallocLog, MALLOC_LOG_FRAMES); + test_memdebug_log_clear(); + break; + } + + case MB_LOG_SYNC: { + extern void sqlite3MemdebugSync(); + test_memdebug_log_clear(); + mallocLogEnabled = 1; + sqlite3MemdebugSync(); + break; } } |