SQLite Forum

Clear shared memory DB and backup problem
Login
Hello everyone, 

Last days I introduced some kind of server cross thread cache based on memory db (file:db_file?mode=memory&cache=shared).

All works fine, but I use backup() function to store this shared memory DB from another sqlite3 instance.

And here is a problem: when I refresh cache, I use backup() again on same existing shared memory DB.
I observe some memory increase (probably some leaks or not cleared existing DB problem).
I assume that should be no memory increase because I backup again same data.
I would like to achieve static memory while putting same data using backup() or other functions to shared memory DB.

Is any way to completely clear memory under (file:db_file?mode=memory&cache=shared).
What are options to remove everything from existing DB or even just destroy current shared memory DB?
I tried to clear it using some tricks: https://stackoverflow.com/questions/21547616/how-do-i-completely-clear-a-sqlite3-database-without-deleting-the-database-file
I also run VACCUM after backup but still I observe memory increasing.