| Previous | Next |
| ERROR_FILE_SYSTEM_VIRTUALIZATION_PROVIDER_UNKNOWN | ERROR_CLOUD_FILE_TOO_MANY_PROPERTY_BLOBS |
ERROR_GDI_HANDLE_LEAK
The process may be leaking GDI objects
ERROR_GDI_HANDLE_LEAK is a Win32 system result. GDI objects such as bitmaps, brushes, pens, fonts, regions, and device contexts consume per-process and system resources. A leak can cause drawing failures, blank controls, resource exhaustion, or instability after long uptime.
What the result means
Windows detected that the application may have leaked Graphics Device Interface handles. For ERROR_GDI_HANDLE_LEAK, keep the symbolic name, numeric value, and failing operation together in diagnostics; that combination distinguishes the exact failure path from nearby system results.
What to check
- Monitor the process GDI object count while repeating the suspected workflow.
- Match every successful object creation with the correct deletion function.
- Restore previously selected objects before deleting them.
- Review error and early-return paths, cached UI resources, and cross-thread ownership.
Recommended handling
Restarting the application may temporarily restore resources but does not fix the leak. Correct ownership and cleanup, then run a long-duration repetition test to prove that the count stabilizes.
Developer notes
Use RAII wrappers for HGDIOBJ and HDC ownership, distinguishing owned handles from borrowed or stock objects. Capture call stacks or allocation sites in diagnostic builds when counts grow. When a Win32 API reports ERROR_GDI_HANDLE_LEAK, capture GetLastError() immediately; subsequent cleanup, formatting, or logging calls can replace the thread-local value.
References
Looking for a different code? Search another status or error code.