Hi,

Encountered what seemed to be somewhat excessive memory consumption for a
relatively simple statement prepare. The following was carried out in
sequence. Platform/environment is Windows CE.

1. System and SQLite memory statistics obtained and recorded
2. Preparation of SQLite statement. The query is : "select docid,
upper(words) from Homonyms;" on table of schema : 'CREATE VIRTUAL TABLE
Homonyms using fts4(words , tokenize=simpleplus "&/"); ' (simpleplus refers
to a custom FTS tokenizer.) There are about 80 records/rows in the table.
3. Statement is finalized.
4. System and SQLite memory statistics obtained and recorded again for
comparison

So comparing memory statistics changes at 4 over 1, the following was noted
(figures are in bytes)
-> dwAvailPhys (system physical memory) decrease by : 1,286,144
-> dwAvailVirtual (system virtual memory) decrease by : 1,376,256
-> SQLITE_STATUS_PAGECACHE_OVERFLOW status increase by : 304,704 (I
understand it here to be page cache use, please correct/enlighten me if I'm
mistaken)
-> SQLITE_STATUS_MEMORY_USED increase by : 801,440 (other general memory
use by SQLite)
-> SQLITE_DBSTATUS_CACHE_USED increase by : 304,704 (memory use for page
cache by database, perhaps understandably identical to the overflow figure
above)
-> SQLITE_DBSTATUS_SCHEMA_USED increase by : 495,224 (memory used to store
database schema - why the sudden increase at this point?)

It was a little strange that such memory consumption could not be observed
when a similar query/statement prepare was carried out on other tables. It
is of concern as we are trying to find ways to reduce or eliminate precious
run-time memory usage by the application where we can.

The following numbers may be superfluous, but hope it will help in better
shedding light on the behaviour. The sections are as reported by the
GlobalMemoryStatus(), sqlite3_status() and sqlite_db_status() functions
respectively.

Many thanks - Herfian

Memory statistics before statement prepare (at 1):

dwLength : 32
dwMemoryLoad : 35
dwTotalPhys : 112959488
dwAvailPhys : 73674752
dwTotalPageFile : 0
dwAvailPageFile : 0
dwTotalVirtual : 1073741824
dwAvailVirtual : 824377344

SQLITE_STATUS_MEMORY_USED       : 1299608
SQLITE_STATUS_MALLOC_SIZE       : 48000
SQLITE_STATUS_MALLOC_COUNT      : 13785
SQLITE_STATUS_PAGECACHE_USED    : 0
SQLITE_STATUS_PAGECACHE_OVERFL  : 342792
SQLITE_STATUS_PAGECACHE_SIZE    : 4232
SQLITE_STATUS_SCRATCH_USED      : 0
SQLITE_STATUS_SCRATCH_OVERFLOW  : 0
SQLITE_STATUS_SCRATCH_SIZE      : 0

SQLITE_DBSTATUS_LOOKASIDE_USED       : 8
SQLITE_DBSTATUS_LOOKASIDE_HIT        : 0
SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE  : 0
SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL  : 0
SQLITE_DBSTATUS_CACHE_USED           : 4808
SQLITE_DBSTATUS_SCHEMA_USED          : 0
SQLITE_DBSTATUS_STMT_USED            : 0

Memory statistics after statement finalize (at 4):

dwLength : 32
dwMemoryLoad : 36
dwTotalPhys : 112959488
dwAvailPhys : 72388608
dwTotalPageFile : 0
dwAvailPageFile : 0
dwTotalVirtual : 1073741824
dwAvailVirtual : 823001088

SQLITE_STATUS_MEMORY_USED       : 2101048
SQLITE_STATUS_MALLOC_SIZE       : 48000
SQLITE_STATUS_MALLOC_COUNT      : 26878
SQLITE_STATUS_PAGECACHE_USED    : 0
SQLITE_STATUS_PAGECACHE_OVERFL  : 647496
SQLITE_STATUS_PAGECACHE_SIZE    : 4232
SQLITE_STATUS_SCRATCH_USED      : 0
SQLITE_STATUS_SCRATCH_OVERFLOW  : 0
SQLITE_STATUS_SCRATCH_SIZE      : 0

SQLITE_DBSTATUS_LOOKASIDE_USED       : 9
SQLITE_DBSTATUS_LOOKASIDE_HIT        : 0
SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE  : 1447
SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL  : 0
SQLITE_DBSTATUS_CACHE_USED           : 309512
SQLITE_DBSTATUS_SCHEMA_USED          : 495224
SQLITE_DBSTATUS_STMT_USED            : 0
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to