I was having a lot of trouble matching up the observed behavior
of sqlite 3.6.12, as it comes pre-installed on Snow Leopard
and on the iphone, with the sqlite documentation, as it pertains
to dynamic memory management. Specifically, it appeared that
sqlite3_soft_heap_limit() was having no effect.

I eventually got the bright idea that Apple may have not built
sqlite with SQLITE_ENABLE_MEMORY_MANAGEMENT turned on. Unless I
overlooked something obvious, it's surprisingly difficult to determine
this when you didn't build sqlite yourself (I eventually ended up
disassembling the code in gdb, and it seemed to match up with the
case where SQLITE_ENABLE_MEMORY_MANAGEMENT was not defined).

I'm developing an iphone application that has a fair bit of
database activity, and I'm wondering if there's anything I
can do to put a ceiling on sqlite's memory consumption while
still using the Apple-supplied sqlite.

In the absence of SQLITE_ENABLE_MEMORY_MANAGEMENT, even if I provide
my own page cache via SQLITE_CONFIG_PAGECACHE, if sqlite decides it
wants to use more than that, it happily will, and the memory stats
will show high values for SQLITE_STATUS_PAGECACHE_OVERFLOW .
This is, presumably, what sqlite3_soft_heap_limit() will limit,
but on the iphone, that appears to be a no-op since they didn't
#define SQLITE_ENABLE_MEMORY_MANAGEMENT.

I thought maybe closing the DB connection, and calling
sqlite3_shutdown() might clear out the "overflow" page cache,
but it didn't seem to have that effect.

So, is there anything I'm overlooking that might help to limit
sqlite's memory allocation for page cache on the iphone (other than
"link in your own configured sqlite .o into your app")?
-harry

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to