diff options
author | drh <drh@noemail.net> | 2008-10-11 15:38:29 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2008-10-11 15:38:29 +0000 |
commit | 4150ebf86fd9935a19dbdc67bdd72e45a1d46a13 (patch) | |
tree | ce22191f363999a0d15eccf9201d975e2b91a598 /src | |
parent | 99655beecf8aaceef5a4122e8cd63e32c565dc26 (diff) | |
download | sqlite-4150ebf86fd9935a19dbdc67bdd72e45a1d46a13.tar.gz sqlite-4150ebf86fd9935a19dbdc67bdd72e45a1d46a13.zip |
Added an assert() to detect lookaside memory leaks. Also added the
SQLITE_OMIT_LOOKASIDE compile-time option which is useful in trying to
track down lookaside memory leaks. (CVS 5800)
FossilOrigin-Name: 0c4c66071a46cecc5f87afb8f8f01ae2c90ee9b3
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 3 | ||||
-rw-r--r-- | src/malloc.c | 8 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c index 97d5475c7..1e6d2d5bf 100644 --- a/src/main.c +++ b/src/main.c @@ -14,7 +14,7 @@ ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** -** $Id: main.c,v 1.506 2008/10/11 15:20:05 drh Exp $ +** $Id: main.c,v 1.507 2008/10/11 15:38:30 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -635,6 +635,7 @@ int sqlite3_close(sqlite3 *db){ sqlite3_mutex_leave(db->mutex); db->magic = SQLITE_MAGIC_CLOSED; sqlite3_mutex_free(db->mutex); + assert( db->lookaside.nOut==0 ); /* Fails on a lookaside memory leak */ if( db->lookaside.bMalloced ){ sqlite3_free(db->lookaside.pStart); } diff --git a/src/malloc.c b/src/malloc.c index 65fdc26d0..2d09af68a 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -12,7 +12,7 @@ ** ** Memory allocation functions used throughout sqlite. ** -** $Id: malloc.c,v 1.42 2008/09/23 16:41:30 danielk1977 Exp $ +** $Id: malloc.c,v 1.43 2008/10/11 15:38:30 drh Exp $ */ #include "sqliteInt.h" #include <stdarg.h> @@ -485,9 +485,13 @@ void sqlite3PageFree(void *p){ /* ** TRUE if p is a lookaside memory allocation from db */ +#ifndef SQLITE_OMIT_LOOKASIDE static int isLookaside(sqlite3 *db, void *p){ return db && p && p>=db->lookaside.pStart && p<db->lookaside.pEnd; } +#else +#define isLookaside(A,B) 0 +#endif /* ** Return the size of a memory allocation previously obtained from @@ -617,6 +621,7 @@ void *sqlite3DbMallocZero(sqlite3 *db, int n){ */ void *sqlite3DbMallocRaw(sqlite3 *db, int n){ void *p; +#ifndef SQLITE_OMIT_LOOKASIDE if( db ){ LookasideSlot *pBuf; if( db->mallocFailed ){ @@ -632,6 +637,7 @@ void *sqlite3DbMallocRaw(sqlite3 *db, int n){ return (void*)pBuf; } } +#endif p = sqlite3Malloc(n); if( !p && db ){ db->mallocFailed = 1; |