You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README-EN.adoc
+37Lines changed: 37 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -620,6 +620,43 @@ You can cache scripts before first execution using the following method to ensur
620
620
621
621
Note that this cache has an unlimited size; be sure to control its size in your application. You can periodically clear the compilation cache by calling the `clearCompileCache` method.
622
622
623
+
=== Clearing DFA Cache
624
+
625
+
QLExpress uses ANTLR4 as its parsing engine. ANTLR4 builds a DFA (Deterministic Finite Automaton) cache at runtime to accelerate subsequent syntax parsing. This cache consumes a certain amount of memory.
626
+
627
+
In some memory-sensitive scenarios, you can call the `clearDFACache` method to clear the DFA cache and release memory.
628
+
629
+
> **IMPORTANT WARNING**: Clearing the DFA cache will cause a significant compilation performance degradation. It is NOT recommended for normal use cases.
630
+
631
+
==== Use Cases
632
+
633
+
* **Memory-sensitive applications**: When memory usage is a critical concern and you can tolerate slower compilation times
634
+
* **Infrequently changing scripts**: When scripts are relatively stable and not frequently recompiled
635
+
636
+
==== Best Practice
637
+
638
+
Call this method immediately after parsing and caching your expression, and ensure all subsequent executions use the cached option to avoid recompilation. Example code:
639
+
640
+
[source,java,indent=0]
641
+
----
642
+
/*
643
+
* When the expression changes, parse it and add it to the expression cache;
644
+
* after parsing is complete, call clearDFACache.
645
+
*/
646
+
Express4Runner runner = new Express4Runner(InitOptions.DEFAULT_OPTIONS);
0 commit comments