On 4/18/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
I performed a simple experiment where i placed printf statements in the 
routines sqlite3FreeX and sqlite3MallocRaw. They seem to be the two lowest 
level routines in SQLite that allocate and deallocate memory. I redirected the 
output to a text file and imported it into Excel (this may have been the hard 
way). I then summed all of the numbers expecting the result to be zero.

What I found was that at the end there was over a MB of memory still allocated.

I can't believe this answer so are there other routines called that allocate 
and deallocate memory?

SQLite is extensively tested for memory leaks, so I would doubt much.
I don't see why you think why those functions you mentioned are the
lower level functions. You are forgetting the sqlite3Realloc one and
by looking at util.c:

[...]
** The above APIs are implemented in terms of the functions provided in the
** operating-system interface. The OS interface is never accessed directly
** by code outside of this file.
**
**     sqlite3OsMalloc()
**     sqlite3OsRealloc()
**     sqlite3OsFree()
**     sqlite3OsAllocationSize()
**
[...]

So, it seems you are not using the lowest levels routines, nor
counting the right high level ones.

Also, SQLite has it's own memory leak detector, which you can enable
to make sure there are no memory leaks (but off course slowing down
your program a lot)

Look at the file util.c. It should give you an idea.

Regards,
~Nuno Lucas


Should I have done this another way?
Ray

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to