What does NTSTATUS 0x803F0001 (STATUS_GDI_HANDLE_LEAK) mean?

 
Previous Next
STATUS_QUERY_STORAGE_ERROR STATUS_SECUREBOOT_NOT_ENABLED

STATUS_GDI_HANDLE_LEAK

Look for an ownership imbalance in GDI object lifetime

STATUS_GDI_HANDLE_LEAK points at potential leakage of GDI objects owned by an application. GDI objects include brushes, pens, fonts, bitmaps, regions and other resources represented by handles. A leak is usually a lifetime problem: an object is created repeatedly but the corresponding release path is skipped, delayed indefinitely, or loses ownership after an error.

GetGuiResources can report the count of GDI objects associated with a process, which makes trend-based diagnosis more useful than taking one isolated count. Exercise the same UI operation repeatedly and watch whether the count returns to its baseline. Then instrument creation and destruction for the object class that grows.

Important ownership rules

  • Objects created by GDI creation functions commonly require DeleteObject when the application owns them.
  • Do not delete an object while it is selected into a device context; restore the previous object first.
  • Stock objects and handles owned by another API have different lifetime rules, so indiscriminate cleanup is unsafe.
  • Check early returns and failed initialization paths as carefully as the normal window-destruction path.

A rising GDI count identifies resource retention, not the exact source line. Pair process-level counts with per-call-site allocation tracing or a debugger so the leaked handle class and owner can be established.

References


Looking for a different code? Search another status or error code.