{"record":{"id":"1548b5fe4fcf95aa","repo":"dotnet/wpf","slug":"d3derr-outofvideomemory","errorCode":"D3DERR_OUTOFVIDEOMEMORY","errorMessage":"SR.MediaContext_OutOfVideoMemory","messagePattern":"SR\\.MediaContext_OutOfVideoMemory","errorType":"exception","errorClass":"OutOfMemoryException","httpStatus":null,"severity":"critical","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaContext.cs","lineNumber":426,"sourceCode":"        /// The partition this media context is connected to went into\n        /// zombie state. This means either an unhandled batch processing,\n        /// rendering or presentation error and will require us to reconnect.\n        /// </summary>\n        private void NotifyPartitionIsZombie(int failureCode)\n        {\n            //\n            // We only get back these kinds of notification:-\n            // For all OOM cases, we get E_OUTOFMEMORY.\n            // For all OOVM cases, we get D3DERR_OUTOFVIDEOMEMORY and\n            // for all other errors we get WGXERR_UCE_RENDERTHREADFAILURE.\n            //\n\n            switch (failureCode)\n            {\n            case HRESULT.E_OUTOFMEMORY:\n                throw new System.OutOfMemoryException();\n            case HRESULT.D3DERR_OUTOFVIDEOMEMORY:\n                throw new System.OutOfMemoryException(SR.MediaContext_OutOfVideoMemory);\n            default:\n                throw new System.InvalidOperationException(SR.MediaContext_RenderThreadError);\n            }\n        }\n\n        /// <summary>\n        /// The back channel processed a malformed packet and so gives\n        /// the notification of invalid packet.\n        /// </summary>\n        private void HandleInvalidPacketNotification()\n        {\n            //\n            // -\n            // For now we ignore the packet and continue processing\n            // other packets. In future, we could also close this channel.\n            //\n        }\n","sourceCodeStart":408,"sourceCodeEnd":444,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaContext.cs#L408-L444","documentation":"When the render partition goes zombie with failure code D3DERR_OUTOFVIDEOMEMORY, MediaContext.NotifyPartitionIsZombie throws OutOfMemoryException(SR.MediaContext_OutOfVideoMemory): the GPU/Direct3D device ran out of video (VRAM) memory, so the renderer cannot continue.","triggerScenarios":"NotifySyncChannelMessage/NotifyChannelMessage delivering partition failure with HRESULT D3DERR_OUTOFVIDEOMEMORY — e.g., too many hardware-accelerated layers, large textures/BitmapCache, or multiple full-screen layered windows exhausting VRAM.","commonSituations":"Apps using many retained BitmapCache / Effect layers, multi-monitor with large desktops on low-VRAM GPUs, remote-desktop sessions where video memory is emulated/limited, driver resets leaking VRAM.","solutions":["Reduce GPU memory usage: remove BitmapCache, shrink cache sizes, avoid stacking many cached visuals or large effects.","Disable or reduce hardware acceleration (RenderOptions.ProcessRenderMode = SoftwareOnly) as a workaround.","Update the GPU driver and test on different hardware; remote into a session with proper GPU support.","Lower resolution/monitor count in the affected scenarios, or release unused images/textures before rendering new ones."],"exampleFix":"// before\nimg.CacheMode = new BitmapCache { RenderAtScale = 4.0 }; // very large VRAM use\n// after\nimg.CacheMode = new BitmapCache { RenderAtScale = 1.0 }; // or remove CacheMode\n// Or force software rendering app-wide:\nRenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;","handlingStrategy":"fallback","validationCode":"// Detect low-acceleration environments and pre-emptively reduce GPU load:\nbyte tier = (byte)(RenderCapability.Tier >> 16);\nbool useCaching = tier >= 2 && !isRemoteSession;","typeGuard":null,"tryCatchPattern":"catch (OutOfMemoryException ex) when (ex.Message.Contains(\"video\")) { RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; ReduceCacheUsage(); }","preventionTips":["Avoid deep stacks of BitmapCache'd visuals and large RenderAtScale values","Update GPU drivers; test on low-VRAM hardware and RDP","Cap the number of simultaneously cached/effects-laden visuals"],"tags":["wpf","vram","direct3d","render-thread","zombie-partition"],"backgroundTag":"out-of-memory","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}