| Previous | Next |
| ERROR_CANCELLED | ERROR_CONNECTION_REFUSED |
ERROR_USER_MAPPED_FILE
The file still has an open user-mapped section.
ERROR_USER_MAPPED_FILE has value 1224 (0x4C8). Windows cannot complete the requested operation on a file while a section created from that file remains mapped into a process. Typical blocked operations include replacement, truncation, some rename or delete paths, and storage maintenance that requires exclusive file state.
Understand the handle chain
A process opens the file, creates a file-mapping object, and maps one or more views. Closing only the original file handle is not enough if the mapping object or mapped view remains alive. Libraries, databases, executable loaders, scanners, and indexers can all hold mappings that are not obvious from the application’s normal file-handle list.
Evidence to collect
- full canonical path, volume identity, and file ID
- requested operation and desired access or sharing flags
- processes holding file, section, or mapped-view references
- whether the file is an executable, DLL, database, archive, or application data
- time of the last successful close or unmap in the owning process
Use trusted handle-inspection tools on an administrative diagnostic path; avoid terminating processes based only on a matching file name.
Correct release order
Stop new access, flush application data as required, call UnmapViewOfFile for every view, close the file-mapping object, and close remaining file handles. Coordinate worker threads before unmapping memory they can still access. After all references are released, repeat the original operation against the same file identity.
When another process owns the mapping
Notify or gracefully stop the owning application or service. During software update, schedule replacement for a maintenance window or reboot when the loaded image cannot be released safely. Forcefully terminating an arbitrary process can corrupt its data and should remain an explicitly authorized last resort.
Developer recommendations
- wrap mapping handles and views in deterministic lifetime objects
- do not cache mapped files indefinitely when updates are expected
- expose a quiesce operation for updaters and backup agents
- log mapping creation and release at debug level with file identity
- test update, delete, and rollback while readers are active
Difference from sharing violations
ERROR_SHARING_VIOLATION usually concerns incompatible open-handle sharing modes. Error 1224 specifically identifies an open mapped section. Reopening the file with broader share flags does not remove an existing memory mapping.
Example
An updater tries to replace a large data file after the application closes its normal stream. A background parser still has a read-only mapped view, so replacement returns 1224. The application’s quiesce protocol stops the parser, unmaps the view, closes the mapping handle, and the updater then performs an atomic replacement.
References
- Microsoft: System Error Codes (1000–1299)
- Microsoft: CreateFileMappingW function
- Microsoft: MapViewOfFile function
- Microsoft: UnmapViewOfFile function
Looking for a different code? Search another status or error code.
