Would you elaborate a bit more on that? To my untrained-in-C eyes it looks like 
there's the outer transaction, then a savepoint1, then a loop of (savepoint2, 
update the only record, release savepoint2). Is savepoint2 there not actually 
getting released each time? Wouldn't the outer transaction and savepoint1 each 
only need to hold the original 2 pages? Which of those is/are eating the 
memory? Is it an SQL problem or a C problem that's causing it? And what's the 
correct way?


-----Original Message-----
From: sqlite-users [mailto:[email protected]] On 
Behalf Of Richard Hipp
Sent: Tuesday, July 25, 2017 1:35 PM
To: SQLite mailing list
Subject: Re: [sqlite] High memory usage for in-memory db with nested 
transactions


Because of the way you have structured your SAVEPOINTs, the statement
log (used to ROLLBACK TO a prior savepoint) must add at least one new
page for each of your 500K UPDATEs.  When the database file is on
disk, the statement log is a temporary file on disk which you are not
noticing.  But when the database file is ":memory:" the statement log
is also in memory.  500K transactions at 4KB per page accounts for
most of the 2GB of memory used.

-- 
D. Richard Hipp
[email protected]
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to