Virtuoso now includes a virtual memory monitor (watchdog) that protects the web server from runaway queries consuming excessive memory. Properly configuring it is crucial for stable, performant SPARQL services.
1. What
The new watchdog monitors the virtual memory (VM) used by Virtuoso’s HTTP threads and enforces limits to prevent system-wide memory exhaustion. It ensures that even under complex or poorly optimized queries, the web server remains safe from crashes.
2. Why
Without such controls, HTTP queries could allocate more memory than available, causing:
- Swapping
- System slowdowns
- Out-of-memory (OOM) kills
The watchdog acts as a circuit breaker: it temporarily locks the web server and kills offending threads until memory usage drops below a safe threshold.
3. How
Two parameters in the [Flags] section of virtuoso.ini control the watchdog:
| Parameter | Description |
|---|---|
| max_proc_vm_size | Maximum virtual memory (KB) the HTTP server may use before locking and killing threads |
| vm_size_wd_threshold | Memory (KB) that must be freed before unlocking the HTTP server |
Mechanism:
- Virtuoso monitors each HTTP thread’s memory usage.
- If VmSize >
max_proc_vm_size, Virtuoso enters maintenance mode and starts killing HTTP threads. - Once memory drops below
vm_size_wd_threshold, the web server is unlocked.
Note: This watchdog monitors HTTP queries only, not SQL/ODBC/JDBC sessions.
Example log entries:
21:56:15 The process Vm size 128061468 went above the limit 128000000, stopping www
21:56:23 The Vm size 115362528 went below limit, enabled www
4. Determining Suitable Values
Step 1 — Check Available Memory
Linux:
free
cat /proc/meminfo | grep -I avail
top
macOS: Activity Monitor → Memory tab
Windows: Task Manager → Performance → Memory
Step 2 — Set max_proc_vm_size
- Choose 70–85% of available memory for
max_proc_vm_size. - This leaves headroom for the OS, file caches, and non-HTTP Virtuoso threads.
Step 3 — Set vm_size_wd_threshold
- Typically 10–20% of max_proc_vm_size, or a fixed buffer (1–10 GB depending on system size).
- This ensures enough memory is freed before the web server resumes operation.
5. Recommended Settings by System Size
| System Size | Example Available Memory | max_proc_vm_size | vm_size_wd_threshold | Notes |
|---|---|---|---|---|
| Small (~2–4 GB) | 2.5 GB | 2,000,000 kB (~2 GB) | 250,000 kB (~0.25 GB) | Suitable for small VPS or developer machines |
| Medium (~8 GB) | 6.6 GB | 4,950,000 kB (~4.95 GB) | 600,000 kB (~0.6 GB) | Typical cloud VM or small server |
| Large (≥64 GB) | 170 GB | 128,000,000 kB (~128 GB) | 10,485,760 kB (~10 GB) | Enterprise servers with heavy SPARQL workloads |
6. Applying Settings
Add to [Flags] in virtuoso.ini:
[Flags]
max_proc_vm_size = <calculated_kB_value>
vm_size_wd_threshold = <threshold_kB_value>
Restart Virtuoso.
7. Summary
- The Virtuoso VM watchdog protects the HTTP server from memory overcommit.
max_proc_vm_sizesets the maximum allowed virtual memory .vm_size_wd_thresholddefines the memory watermark for unlocking the server.- Use system memory measurements to select safe values.
- Log entries confirm when limits are exceeded and when memory is back under threshold.
Following this approach ensures that Virtuoso remains stable under heavy HTTP query loads, preventing system crashes while maintaining high availability.