paulk-asert opened a new pull request, #2840: URL: https://github.com/apache/groovy/pull/2840
AtnManager has two mechanisms for dropping the shared parser DFA cache, but they were mutually exclusive. isSmartCleanupEnabled() is defined as DFA_CACHE_THRESHOLD == 0, and the canary clear was guarded by shouldClearDfaCache() && isSmartCleanupEnabled(), so setting any positive groovy.antlr4.cache.threshold switched the GC canary off. Since the threshold is the documented knob for bounding DFA cache growth, reaching for it to reduce memory use silently removed the only mechanism that responds to actual memory pressure. This was hit in practice: a user chasing an OOM on 5.1.1 under Maven at -Xmx128m set threshold=200 as a mitigation, which made 5.1.0 start OOMing too because it disabled the valve that had been keeping it alive. Derive two independent switches from the raw property instead of overloading one: GC_CANARY_ENABLED (t >= 0) and DFA_CACHE_THRESHOLD (max(t, 0)). Behaviour changes only for a positive threshold, which now keeps the canary as well as the counter. Zero (the default) is unchanged, so there is no throughput cost for users who do not set the property, and a negative value remains the explicit "never clear" escape hatch — it now switches off both mechanisms, since the canary is no longer implied by a zero threshold. The forked-JVM test fails without the fix: with threshold=25 and only 12 parses the counter cannot fire, and after the JVM clears soft references the parser DFA state count goes 478 -> 486 instead of dropping. This does not on its own close the 5.1.1 memory regression. At the default the canary is still only observed on the parse path, so under a tight heap the cache can go unreclaimed until an OOM that arrives mid-parse. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
