About the problem that the database size remains unchanged after sqlite3 deletes the data in the table

    Recently, due to the needs of the project, sqlite3 database related operations have been used. Because the one that comes with QT was used before, not C language to operate, but in general, the difference is not big. Before, in the process of operating the database, the memory will continue to increase. Later, it was found that a lot of memory was not released during the operation. But there is a new problem recently. After I delete the data in the table, I find that the size of the database file is still the same, and the next time I open the database, I find that it still occupies the memory of the system. After a lot of searching, I finally found the root cause. It turns out that after deleting data from Sqlite, unused disk space is added to an internal "free list" for storing the data you insert next time. Disk space is not lost. But also doesn't return disk space to the OS. You need to manually execute the VACUUM command to delete.

    Remember, the VACUUM command will fail if other operations or transaction operations are in progress.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325589668&siteId=291194637