{"record":{"id":"6b710032a3908123","repo":"MathewSachin/Captura","slug":"there-is-already-the-maximum-number-of-application","errorCode":null,"errorMessage":"There is already the maximum number of applications using the Desktop Duplication API running, please close one of the applications and try again.","messagePattern":"There is already the maximum number of applications using the Desktop Duplication API running, please close one of the applications and try again\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/Captura.Windows/DesktopDuplication/DuplCapture.cs","lineNumber":66,"sourceCode":"            }\n        }\n\n        public void Init()\n        {\n            lock (_syncLock)\n            {\n                _frameGrabber?.Dispose();\n                _deskDupl?.Dispose();\n\n                try\n                {\n                    _deskDupl = _output.DuplicateOutput(_device);\n\n                    _frameGrabber = new FrameGrabber(_deskDupl);\n                }\n                catch (SharpDXException e) when (e.Descriptor == ResultCode.NotCurrentlyAvailable)\n                {\n                    throw new Exception(\n                        \"There is already the maximum number of applications using the Desktop Duplication API running, please close one of the applications and try again.\",\n                        e);\n                }\n                catch (SharpDXException e) when (e.Descriptor == ResultCode.Unsupported)\n                {\n                    throw new NotSupportedException(\n                        \"Desktop Duplication is not supported on this system.\\nIf you have multiple graphic cards, try running Captura on integrated graphics.\",\n                        e);\n                }\n            }\n        }\n\n        public bool Get(Texture2D Texture, DxMousePointer DxMousePointer, Point TargetPosition = default)\n        {\n            lock (_syncLock)\n            {\n                // Disposed\n                if (_device == null)","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/MathewSachin/Captura/blob/3fdf41529bf4d50cd7a85aedd856f30e34279a47/src/Captura.Windows/DesktopDuplication/DuplCapture.cs#L48-L84","documentation":"Thrown by DuplCapture.Init (src/Captura.Windows/DesktopDuplication/DuplCapture.cs:66) when output.DuplicateOutput raises a SharpDXException whose Descriptor equals DXGI ResultCode.NotCurrentlyAvailable. That DXGI code means the Desktop Duplication API has already reached its maximum allowed concurrent duplications for the session/output.","triggerScenarios":"Calling Output1.DuplicateOutput when the DXGI desktop duplication limit is already saturated. DXGI allows a fixed number of active OutputDuplication interfaces; once exceeded, duplication returns NotCurrentlyAvailable.","commonSituations":"Another screen recorder, streaming/overlay tool (OBS, Steam, Discord share), or a previous DuplCapture instance that was not Disposed is holding a duplication on the same output; Captura itself leaked a DuplCapture by forgetting to Dispose.","solutions":["Dispose all prior DuplCapture instances (free their OutputDuplication) before creating a new one.","Close other applications using the Desktop Duplication API on this output, then retry Init.","If the count recovers, allow Init to be retried after a short delay.","Track active duplications per output and refuse over-allocation up front."],"exampleFix":"// before\n_deskDupl = _output.DuplicateOutput(_device);\n// after - ensure previous duplication released first, then retry once\n_deskDupl?.Dispose();\ntry { _deskDupl = _output.DuplicateOutput(_device); }\ncatch (SharpDXException e) when (e.Descriptor == ResultCode.NotCurrentlyAvailable)\n    when (await RetryOnceAfter(500)) { _deskDupl = _output.DuplicateOutput(_device); }","handlingStrategy":"retry","validationCode":"// ensure no leaked duplication before creating one\nforeach (var c in ActiveCaptures) c.Dispose();\nActiveCaptures.Clear();\n// only then call Init()","typeGuard":null,"tryCatchPattern":"try { capture.Init(); }\ncatch (Exception e) when (e.InnerException is SharpDXException sx && sx.Descriptor == ResultCode.NotCurrentlyAvailable) { /* ask user to close other duplication apps, then retry once */ }","preventionTips":["Always Dispose DuplCapture instances; track them per output.","Detect other duplication users and warn before capturing.","Expose Init() as retryable so a transient saturation can recover."],"tags":["desktop-duplication","dxgi","sharpdx","resource-limit","windows","csharp"],"backgroundTag":null,"analyzedSha":"3fdf41529bf4d50cd7a85aedd856f30e34279a47","analyzedAt":"2026-08-13T19:35:27.486Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}