FireDAC Connection Pool Exhaustion: Diagnostic Guide for RAD Studio
When RAD Studio applications hang due to FireDAC pool exhaustion, follow this ordered diagnostic guide to identify root causes and apply targeted fixes.
20 Nov 2026, 19:52 UTC

Recognizable condition
FireDAC maintains an in-process connection pool to reduce the overhead of opening new sessions. When idle connections are not released-or when long-running transactions hold slots-the pool fills, subsequent queries block or fail with 'SQLConnection not available'. Applications built on VCL forms are especially sensitive because UI threads must remain responsive; if pool operations block the main thread, the entire interface freezes.
Cause diagnostic table
| Finding | Detail |
|---|---|
| Symptom | Application hangs or throws 'SQLConnection not available' after prolonged use; diagnostic log shows pool max reached. |
| Root cause | Idle connections not released due to missing Close or Dispose calls, or long-running transactions without commit/rollback. |
Ordered checks
- Verify connection state – Before opening a new FDConnection, confirm that FDConnection.Connected is True and that any FDQuery instance is not active (FDQuery.Active = False). Opening a connection while another is active can silently inflate the pool count.
- Inspect pool parameters – Open the Object Inspector or examine code to read FDConnection.Params. Locate the PoolName and PoolSize entries. The default PoolSize is often 10; adjust it to match your concurrency profile (e.g., 20-50 for typical business applications).
- Check query lifecycle – Ensure every FDQuery.Close call precedes component destruction. Place cleanup in a Try/Finally block to guarantee release even when exceptions occur:
try FDQuery.Open; // operate on data finally if FDQuery.Active then FDQuery.Close; end - Review transaction scope – Long-running transactions that are never committed or rolled back hold pool slots. Commit after business logic completes, or issue a rollback on error paths.
Fixes tied to findings
- Set PoolSize appropriately – In the Object Inspector, expand FDConnection.Params and set PoolSize to a value that anticipates peak concurrent sessions without exhausting the database server's limit. For FireDAC versions RAD Studio XE through 12, the parameter key remains PoolSize, but verify the dictionary spelling for your target release; earlier versions may expose Cache-related keys that differ.
- Guarantee query closure – Adopt the Try/Finally pattern shown above in every code path that creates an FDQuery. This eliminates the most common leak: a query left open after a form closes.
- Commit or rollback transactions promptly – Wrap transaction logic in explicit Commit/Rollback calls. Avoid the pattern of open transaction at startup, close at shutdown.
Escalation criteria
If pool exhaustion persists after applying the above fixes, investigate deeper layers:
- Thread affinity – FireDAC pool operations must run on the thread that created the connection. Crossing threads can cause the pool to appear exhausted while the actual slot is held on a blocked thread. Use FDConnection.Connected checks on the creation thread, or marshal calls via TThread.Synchronize.
- Database server limits – A DBA should audit the server-side max_connections setting and compare it to the application's PoolSize. If the app requests 100 connections but the server allows 50, the pool will never stabilize.
- VCL UI blocking – If pool-related calls happen on the main VCL thread, they may trigger an access violation. Offload pool monitoring to a background thread and communicate results through thread-safe queues.
Practical verification after the fix
- Run a stress test with 100 concurrent sessions (e.g., using a load-testing tool or scripted client).
- Monitor FDConnection.PoolSize and the active connection count in the LiveBindings debugger variable watch; both should remain stable across the test duration.
- Check Windows Event Viewer or your application log for Pool exhausted warnings after the test—these should disappear.
- Compare FDConnection.Params before and after the fix using the debugger; PoolSize should reflect your intended value, and PoolUsage (if exposed) should stay well below the cap.
Limitations – The FireDAC pool is an in-process cache; it does not replace server-side connection management. Very high-throughput systems may still need connection pooling at the DBMS level. Additionally, VCL forms require main-thread UI access; crossing threads for pool operations may cause an access violation if not synchronized properly.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.