Skip to content

Commit

Permalink
Call sqlite3_db_release_memory when we discard a connection.
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Sep 17, 2024
1 parent 9c34e52 commit 8d139ff
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ext/sqlite3/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ close_or_discard_db(sqlite3RubyPtr ctx)
"is being discarded. This is a memory leak. If possible, please close all sqlite "
"database connections before forking.");

// release as much heap memory as possible by deallocating non-essential memory
// allocations held by the database library. Memory used to cache database pages to
// improve performance is an example of non-essential memory.
sqlite3_db_release_memory(ctx->db);

#ifdef HAVE_SQLITE3_DB_NAME
const char *db_name;
int j_db = 0;
Expand Down

0 comments on commit 8d139ff

Please sign in to comment.