File tree Expand file tree Collapse file tree
src/main/java/org/perlonjava/runtime/runtimetypes Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -188,17 +188,23 @@ public static void weaken(RuntimeScalar ref) {
188188 ref .refCountOwned = false ;
189189 base .refCount = WEAKLY_TRACKED ;
190190 }
191- boolean shouldSweepLiveCodeRef = weakenedLiveCodeRef
191+ boolean shouldCheckLiveCodeRef = weakenedLiveCodeRef
192192 && codeRefHasCountedOwners (base )
193193 && !ModuleInitGuard .inModuleInit ();
194194 if (base instanceof RuntimeCode code
195195 && code .refCount >= 0
196196 && weakRefsExist
197- && (shouldSweepLiveCodeRef
197+ && (shouldCheckLiveCodeRef
198198 || (code .hadStashRef
199199 && code .stashRefCount <= 0
200200 && !isInstalledGlobalCodeRef (code )))) {
201- ReachabilityWalker .sweepWeakRefs (true );
201+ // Keep this path targeted to the CODE referent. DBIC weakens
202+ // callback CODE refs in hot cursor paths; running a full
203+ // ReachabilityWalker sweep here forces repeated System.gc() calls.
204+ // The CODE-specific stale-ref decision below is enough: live CODE
205+ // refs are protected by clearWeakRefsTo()/shouldKeepCodeWeakRefs,
206+ // while expired anonymous or former-stash CODE refs can still clear
207+ // their weak registry entries immediately.
202208 if (hasWeakRefsTo (code )
203209 && code .stashRefCount <= 0
204210 && !isInstalledGlobalCodeRef (code )
You can’t perform that action at this time.
0 commit comments