Hmm.  I see that sqlite3PcacheReleaseMemory() is a no-op
if sqlite3GlobalConfig.nPage is non-zero, and that happens
when SQLITE_DEFAULT_PCACHE_INITSZ is not zero.  If I compile with
-DSQLITE_DEFAULT_PCACHE_INITSZ=0 , then I see the expected pages freed.
AFAICT, it doesn't matter if you make use of more than
SQLITE_DEFAULT_PCACHE_INITSZ pages, it still doesn't free the excess.

Looks like that was added in 3.8.11 back in July.

-scott


On Thu, Jan 7, 2016 at 5:44 AM, Bart Smissaert <bart.smissaert at gmail.com>
wrote:

> These are the compile flags of my sqlite3.dll:
>
> compile_option
> ----------------------------------------------------
> DEBUG
> ENABLE_COLUMN_METADATA
> ENABLE_MEMORY_MANAGEMENT
> MEMDEBUG
> OMIT_LOOKASIDE
> THREADSAFE=0
>
> And these are the set pragma's:
>
> PRAGMA cache_size 32768
> PRAGMA default_cache_size 32768
> PRAGMA page_count 712711
> PRAGMA max_page_count 1073741823
> PRAGMA page_size 1024
> PRAGMA journal_size_limit -1
> PRAGMA locking_mode normal
> PRAGMA automatic_index 1
> PRAGMA encoding UTF-8
> PRAGMA ignore_check_constraints 0
> PRAGMA read_uncommitted 0
> PRAGMA recursive_triggers 0
> PRAGMA reverse_unordered_selects 0
> PRAGMA secure_delete 0
> PRAGMA wal_autocheckpoint 1000
> PRAGMA writable_schema 0
> PRAGMA journal_mode off
> PRAGMA auto_vacuum NONE
> PRAGMA synchronous OFF
> PRAGMA temp_store DEFAULT
>
>
> RBS
>
> On Thu, Jan 7, 2016 at 1:39 PM, Bart Smissaert <bart.smissaert at gmail.com>
> wrote:
>
> > > So you should
> > see results if you start a transaction, do a few update statements,
> commit
> > the transaction, the call sqlite3_release_memory(db).
> >
> > I tried this with a large table, first with no transaction then with a
> > transaction
> > and tried the sqlite3_release_memory directly after the sqlite3_finalize,
> > but in both cases result still zero:
> >
> > sqlite3_memory_used: 37190712
> > sqlite3_release_memory:    0
> > sqlite3_memory_used: 37190712
> >
> > This was a single update, where I don't think a transaction is helpful.
> > Still no idea how I can make sqlite3_release_memory produce non-zero.
> >
> > RBS
> >
> >
> >
> > On Thu, Jan 7, 2016 at 6:05 AM, Scott Hess <shess at google.com> wrote:
> >
> >> On Wed, Jan 6, 2016 at 3:03 PM, Bart Smissaert <
> bart.smissaert at gmail.com>
> >> wrote:
> >>
> >> > Have compiled sqlite3.dll (latest) compiled with
> >> ENABLE_MEMORY_MANAGEMENT,
> >> > but sofar
> >> > not been able yet to make sqlite3_release_memory produce anything else
> >> than
> >> > 0.
> >> > What would be the simplest way to make this happen?
> >> > I don't want to do this with C coding, so it should be some SQL
> >> scenario or
> >> > to do with simple
> >> > SQLite functions such as sqlite3_step, _prepare, -finalize etc.
> >>
> >>
> >> Last time I was paying attention to this, I believe that I found that
> the
> >> biggest effect was to free unpinned pages from the page cache.  So it
> >> might
> >> not free pages if you're in a transaction, for instance.  I would guess
> >> that if you had memory-mapped mode on and are doing only reads, there
> >> would
> >> be no pages to free (mmap pages aren't in the page cache).  So you
> should
> >> see results if you start a transaction, do a few update statements,
> commit
> >> the transaction, the call sqlite3_release_memory(db).
> >>
> >> -scott
> >> _______________________________________________
> >> sqlite-users mailing list
> >> sqlite-users at mailinglists.sqlite.org
> >> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> >>
> >
> >
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>

Reply via email to