为何Chrome(Windows)中Kantu 2.5.0脚本运行逐渐变慢?
I’ve run into this exact slowdown issue with Kantu long-running loops before, especially on older versions like 2.5.0 paired with Chrome 64. The root cause usually boils down to memory bloat or inefficient loop scheduling. Here are some practical, tested fixes:
1. Add Memory Cleanup to Your Script
Over time, Kantu accumulates cached DOM elements and browser storage data, which drags down performance. Insert these commands into your loop (try running them every 10 cycles to balance cleanup overhead and memory savings):
store | true | !clearBrowserCache store | true | !clearStorage
These commands wipe temporary cache and local storage, preventing memory leaks from slowing down your click actions.
2. Use Native Infinite Loop Syntax Instead of a Huge Loop Count
You don’t need to input 999999999 to simulate infinite loops—Kantu has built-in logic for this that’s far more efficient. Rewrite your script with a gotoIf loop:
label | loop_start # Replace with your actual click command, e.g.: click | css=.target-button pause | 2000 gotoIf | true | loop_start
This native loop avoids the performance overhead of tracking an enormous loop counter, which is likely part of why your script slows down over time.
3. Optimize Chrome for Long-Running Scripts
Older Chrome versions can hog memory when running extensions for hours. Tweak these settings:
- Disable unused extensions: Go to
chrome://extensions/and turn off everything except Kantu to free up memory. - Enable memory saver: Navigate to
chrome://settings/systemand toggle on "Memory saver" to auto-release memory from idle tabs. - Disable preloading: Turn off "Preload pages for faster browsing and searching" in
chrome://settings/preloadto cut down on background resource usage.
4. Periodically Restart the Kantu Extension
Since you’re using an older Kantu version (2.5.0), it might have memory leaks that can’t be fully fixed with script tweaks. Setting a reminder to restart Kantu every 1-2 hours will immediately reset its memory usage and restore your script’s original speed.
内容的提问来源于stack exchange,提问作者Elemenop

