// sqlite · memory

soft_heap_limit

Advisory ceiling on the heap memory SQLite may use across every connection in the process.

Par défaut
0 (no limit)
Range
0 or more bytes
Restart needed
Non
Default checked on
SQLite 3.5x

Ce que cela fait

The limit is process wide, not per connection. As usage climbs toward it, SQLite shrinks page caches to stay under. It is advisory: SQLite will cross the limit rather than fail a query with SQLITE_NOMEM. Setting 0 removes the limit; values that are not non-negative integers leave it unchanged.

Valeur par défaut

0 (no limit). 0 (a stock SQLite 3.5x build), meaning the limit is disabled.

Check the current value

PRAGMA soft_heap_limit;

SELECT * FROM pragma_soft_heap_limit;   -- table-valued form, usable in queries

Change it

PRAGMA soft_heap_limit = 268435456;   -- this connection only

No restart. It applies at once to the connection that runs it and is lost when that connection closes, so set it every time a connection opens.

When to change it

In one process that hosts many connections on a memory-constrained device, to tell SQLite to give page-cache memory back as usage grows.

What can go wrong

It bends instead of holding: a query that genuinely needs the memory still gets it, so treat this as a hint for cache trimming. One connection's PRAGMA moves the ceiling for every connection in the process.

Questions about soft_heap_limit

What is the default value of soft_heap_limit in SQLite?

0 (no limit). 0 (a stock SQLite 3.5x build), meaning the limit is disabled.

Does changing soft_heap_limit require a restart?

No. No restart. It applies at once to the connection that runs it and is lost when that connection closes, so set it every time a connection opens.

When should I change soft_heap_limit?

In one process that hosts many connections on a memory-constrained device, to tell SQLite to give page-cache memory back as usage grows.

Back to all SQLite settings, or check the SQLite manual for every option.

// one client for every engine

Check soft_heap_limit on your own server

SQLly runs the query above against SQLite and the other engines in this reference, from one desktop app on macOS, Windows and Linux.

Texte et données de cette page : CC BY 4.0, en citant SQLly (sqlly.app). Code et extraits SQL : MIT. Détails de la licence