SQLite Forum

Memory-mapped IO used for temp files even though memory-mapped I/O is not used
Login
Hi,

While investigating out-of-memory issues, we noticed that during large sort operations, memory usage spikes. It turns out SQLite uses memory-mapped file I/O for temp files, which can be GBs in size in our case.

The mmap_size PRAGMA is never used.

It looks like this bit of code in `vdbeSorterOpenTempFile` (vdbesort.c) is setting the Mmap max to ~2GB:
```
    i64 max = SQLITE_MAX_MMAP_SIZE;
    sqlite3OsFileControlHint(*ppFd, SQLITE_FCNTL_MMAP_SIZE, (void*)&max);
```

To work around this, we set SQLITE_MAX_MMAP_SIZE=0.

Is this expected behavior?

Platform: Windows 32-bit.