# soft_heap_limit

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

Source: https://sqlly.app/sql-configuration/sqlite/soft-heap-limit
Last updated: 2026-11-30
License: Text and data [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) (credit SQLly, sqlly.app); code and SQL snippets [MIT](https://opensource.org/license/mit). [Details](https://sqlly.app/license).

**Default**

`0 (no limit)`

**Range**

0 or more bytes

**Restart needed**

No

**Default checked on**

SQLite 3.5x

## What it does

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.

## Default value

`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](https://sqlly.app/sql-configuration/sqlite), or check the [SQLite manual](https://www.sqlite.org/pragma.html) for every option.

## Related SQLite settings

- [`cache_size` Page cache size for this connection: positive numbers are pages, negative numbers are KiB.](https://sqlly.app/sql-configuration/sqlite/cache-size)
- [`temp_store` Where temporary tables and indexes go: compile-time default, file or memory.](https://sqlly.app/sql-configuration/sqlite/temp-store)

## Related on SQLly

- [SQLite query performance troubleshooting Performance guide](https://sqlly.app/sql-performance/sqlite)
