Hi,
I have sent the following mail to [EMAIL PROTECTED] about a month ago. But I
got no reply and as far as I can see my patch has not been applied in the
sqlite cvs so far.
If [EMAIL PROTECTED] is the wrong address to send sqlite development issues,
what is the right one? I can only find a pointer to this 'sqlite users'
list on the webpage.
yours,
- clifford
On Mon, Sep 12, 2005 at 01:04:13PM +0200, Clifford Wolf wrote:
> Hi,
>
> I'm the developer of a scripting language called SPL. This scripting
> language also has a module for accessing sqlite databases.
>
> I'm using valgrind for checking for memory leaks in SPL. When profiling
> scripts which do access SQLite databases, I've found that the lockHash and
> openHash data structures in os_unix.c don't get freed.
>
> I wouldn't consider that a real memory leak, but it doesn't look nice in
> memory profilers such as valgrind. That's why I recommend the attached
> patch. Please let me know how you think about it..
>
> yours,
> - clifford
--snip--
Clifford Wolf:
Fixed kind-of-memory-leak in sqlite-3.2.0 for unix platforms
(This is not really a memory leak - just unfreed memory which
is confusing valgrind and other leak checkers..)
--- sqlite-3.2.0/src/os_unix.c 2005-09-09 23:21:57.000000000 +0200
+++ sqlite-3.2.0/src/os_unix.c 2005-09-10 22:38:29.000000000 +0200
@@ -231,6 +231,9 @@
static Hash lockHash = { SQLITE_HASH_BINARY, 0, 0, 0, 0, 0 };
static Hash openHash = { SQLITE_HASH_BINARY, 0, 0, 0, 0, 0 };
+static int lockHashCounter = 0;
+static int openHashCounter = 0;
+
#ifdef SQLITE_UNIX_THREADS
/*
@@ -302,6 +305,8 @@
pLock->nRef--;
if( pLock->nRef==0 ){
sqlite3HashInsert(&lockHash, &pLock->key, sizeof(pLock->key), 0);
+ if (--lockHashCounter == 0)
+ sqlite3HashClear(&lockHash);
sqliteFree(pLock);
}
}
@@ -313,6 +318,8 @@
pOpen->nRef--;
if( pOpen->nRef==0 ){
sqlite3HashInsert(&openHash, &pOpen->key, sizeof(pOpen->key), 0);
+ if (--openHashCounter == 0)
+ sqlite3HashClear(&openHash);
sqliteFree(pOpen->aPending);
sqliteFree(pOpen);
}
@@ -360,6 +367,7 @@
pLock->cnt = 0;
pLock->locktype = 0;
pOld = sqlite3HashInsert(&lockHash, &pLock->key, sizeof(key1), pLock);
+ lockHashCounter++;
if( pOld!=0 ){
assert( pOld==pLock );
sqliteFree(pLock);
@@ -383,6 +391,7 @@
pOpen->nPending = 0;
pOpen->aPending = 0;
pOld = sqlite3HashInsert(&openHash, &pOpen->key, sizeof(key2), pOpen);
+ openHashCounter++;
if( pOld!=0 ){
assert( pOld==pOpen );
sqliteFree(pOpen);
--snap--
--
SSSS PPPP L The SPL Programming Language
S P P L http://www.clifford.at/spl/
SSSS PPPP L ----------------------------------------------------
S P L An object oriented, stateful, simple, small, c-like,
SSSS P LLLL embeddable, feature rich, dynamic scripting language
Qrpelcgvat ebg13 ivbyngrf gur QZPN! Cercner gb or fhrq!!