Small. Fast. Reliable.
Choose any three.
Search for:

SQLite C Interface

Impose A Limit On Heap Size

sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);

R-54493-30181:[The sqlite3_soft_heap_limit64() interface sets and/or queries the soft limit on the amount of heap memory that may be allocated by SQLite. ] R-27925-06263:[SQLite strives to keep heap memory utilization below the soft heap limit by reducing the number of pages held in the page cache as heap memory usages approaches the limit. ] R-54035-60779:[The soft heap limit is "soft" because even though SQLite strives to stay below the limit, it will exceed the limit rather than generate an SQLITE_NOMEM error. ] In other words, the soft heap limit is advisory only.

R-47776-28526:[The return value from sqlite3_soft_heap_limit64() is the size of the soft heap limit prior to the call, or negative in the case of an error. ] R-59203-27417:[If the argument N is negative then no change is made to the soft heap limit. ] Hence, the current size of the soft heap limit can be determined by invoking sqlite3_soft_heap_limit64() with a negative argument.

R-06665-27325:[If the argument N is zero then the soft heap limit is disabled. ]

R-61080-17963:[The soft heap limit is not enforced in the current implementation if one or more of following conditions are true:


Beginning with SQLite version 3.7.3 (2010-10-08), the soft heap limit is enforced regardless of whether or not the SQLITE_ENABLE_MEMORY_MANAGEMENT compile-time option is invoked. With SQLITE_ENABLE_MEMORY_MANAGEMENT, the soft heap limit is enforced on every memory allocation. Without SQLITE_ENABLE_MEMORY_MANAGEMENT, the soft heap limit is only enforced when memory is allocated by the page cache. Testing suggests that because the page cache is the predominate memory user in SQLite, most applications will achieve adequate soft heap limit enforcement without the use of SQLITE_ENABLE_MEMORY_MANAGEMENT.

The circumstances under which SQLite will enforce the soft heap limit may changes in future releases of SQLite.

See also lists of Objects, Constants, and Functions.