How to reduce SQLite memory consumption?

前端 未结 4 1637
眼角桃花
眼角桃花 2021-01-31 20:56

I\'m looking for ways to reduce memory consumption by SQLite3 in my application.

At each execution it creates a table with the following schema:

(main TE         


        
4条回答
  •  青春惊慌失措
    2021-01-31 21:03

    It seems that the high memory consumption may be caused by the fact that too many operations are concentrated in one big transaction. Trying to commit smaller transaction like per 1M operations may help. 5M operations per transaction consumes too much memory.

    However, we'd balance the operation speed and memory usage.

    If smaller transaction is not an option, PRAGMA shrink_memory may be a choice.

    Use sqlite3_status() with SQLITE_STATUS_MEMORY_USED to trace the dynamic memory allocation and locate the bottleneck.

提交回复
热议问题