{"record":{"id":"08131eadae88ea11","repo":"egametang/ET","slug":"fiber-local-slot-exhausted-zone-zone-nextloca","errorCode":null,"errorMessage":"fiber local slot exhausted, zone: {zone}, nextLocalSlot: {localSlot}, dynamic range: [{FiberIdHelper.DynamicLocalSlotStart}, {FiberIdHelper.ReservedLocalSlotStart - 1}]","messagePattern":"fiber local slot exhausted, zone: (.+?), nextLocalSlot: (.+?), dynamic range: \\[(.+?), (.+?)\\]","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"Packages/cn.etetet.core/Scripts/Core/Share/World/Fiber/FiberManager.cs","lineNumber":200,"sourceCode":"            catch (Exception e)\n            {\n                throw new Exception($\"create fiber error: {fiberId} {sceneType}\", e);\n            }\n        }\n\n        private int AllocateLocalSlot(int zone)\n        {\n            FiberIdHelper.ValidateZone(zone);\n\n            lock (this.localSlotLock)\n            {\n                int localSlot = this.nextLocalSlotByZone.TryGetValue(zone, out int nextLocalSlot)\n                        ? nextLocalSlot\n                        : FiberIdHelper.DynamicLocalSlotStart;\n\n                if (localSlot >= FiberIdHelper.ReservedLocalSlotStart)\n                {\n                    throw new Exception(\n                        $\"fiber local slot exhausted, zone: {zone}, nextLocalSlot: {localSlot}, dynamic range: [{FiberIdHelper.DynamicLocalSlotStart}, {FiberIdHelper.ReservedLocalSlotStart - 1}]\");\n                }\n\n                this.nextLocalSlotByZone[zone] = localSlot + 1;\n                return localSlot;\n            }\n        }\n\n        /// <summary>\n        /// 创建纤程\n        /// </summary>\n        /// <param name=\"schedulerType\">纤程调度器，-1: 主线程，-2: 当前线程，-3: 线程池, 其它: 纤程</param>\n        /// <param name=\"rootId\"></param>\n        /// <param name=\"zone\">区</param>\n        /// <param name=\"sceneType\">场景类型</param>\n        /// <param name=\"name\">纤程名称</param>\n        /// <param name=\"parent\"></param>\n        /// <returns>纤程id</returns>","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.core/Scripts/Core/Share/World/Fiber/FiberManager.cs#L182-L218","documentation":"AllocateLocalSlot (FiberManager line 200) throws when the dynamic local-slot counter for a zone reaches ReservedLocalSlotStart (int.MaxValue - 15). Slots are allocated per zone starting at DynamicLocalSlotStart (100000) and monotonically incremented; the code never recycles freed slots, so exhaustion implies an unbounded fiber-creation leak within one process lifetime.","triggerScenarios":"Creating more than ~2.1 billion fibers in a single zone (dynamic range 100000..int.MaxValue-16) without restart - effectively a runaway loop that spawns fibers and never disposes them, or fibers created in a hot loop without pooling.","commonSituations":"A server that repeatedly creates transient fibers per request/message without tearing them down, a reconnect storm, a bug creating a fiber inside an update loop, or an extremely long-lived process accumulating fibers.","solutions":["Find and fix the fiber leak - ensure every CreateFiber has a matching Dispose/teardown and that no update loop spawns unbounded fibers.","Pool/reuse fibers for repeated transient work instead of allocating new ones.","If legitimate long-lived load needs many fibers, restart the process on a schedule (the slot space is per-process and not recycled).","Add instrumentation counting live fibers per zone to detect the leak early."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return fiberManager.CreateFiber(...); }\ncatch (Exception e) when (e.Message.Contains(\"fiber local slot exhausted\"))\n{ Log.Error($\"fiber slot exhaustion - likely fiber leak, restarting zone: {e}\"); throw; }","preventionTips":["Always pair CreateFiber with teardown/Dispose.","Never create fibers inside a per-frame/per-message loop without bounds.","Pool transient fibers.","Instrument live-fiber counts per zone and alert before exhaustion."],"tags":["fiber","memory-leak","startup","concurrency"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}