| Previous | Next |
| STG_E_PATHNOTFOUND | STG_E_ACCESSDENIED |
STG_E_TOOMANYOPENFILES
What is exhausted
STG_E_TOOMANYOPENFILES is a resource-exhaustion result, not a statement that the compound document itself is malformed. Structured Storage can return it while opening or modifying storages and streams when the process or its environment can no longer obtain the handles it needs. The immediate trigger may be a file-handle leak, a long-lived cache of IStorage/IStream objects, excessive parallel document processing, or a platform limit reached by the worker process.
Compound files are hierarchical. Keeping one root storage open can also keep child streams, locks, and backing file state alive, so counting only top-level document objects may hide the leak.
How to investigate
- Measure open handles over time for the actual worker process, especially across failed imports and cancellation paths.
- Release COM storage and stream interfaces deterministically; ensure exception paths release every object that was already acquired.
- Bound concurrent processing of documents rather than opening every queued item at once.
- Reproduce with a small fixed document set. A steadily rising handle count points to lifecycle management, while an immediate failure at high concurrency points to capacity.
References
- Microsoft: IStorage::OpenStorage return values
- Apache POI: POIFS lifecycle and compound files
- OpenMcdf: .NET compound-file implementation
Looking for a different code? Search another status or error code.