SuperMonster003 / AutoJs6

安卓平台 JavaScript 自动化工具 (Auto.js 二次开发项目)
https://docs.autojs6.com
Mozilla Public License 2.0
2.16k stars 656 forks source link

报错,版本v6.4.1,这种报错常出 #165

Open nsy9601 opened 8 months ago

nsy9601 commented 8 months ago

点运行脚本时就出现了下面的报错,实际上脚本的第一行都没有执行,因为第一行的console.log()都没输出

10:37:28.248/E: Failed to allocate a 272 byte allocation with 410360 free bytes and 400KB until OOM, target footprint 268435456, growth limit 268435456; giving up on allocation because <1% of heap free after GC.

java.lang.OutOfMemoryError: Failed to allocate a 272 byte allocation with 410360 free bytes and 400KB until OOM, target footprint 268435456, growth limit 268435456; giving up on allocation because <1% of heap free after GC. at org.mozilla.javascript.InterpreterData.init(Unknown Source:12) at org.mozilla.javascript.InterpreterData.(InterpreterData.java:37) at org.mozilla.javascript.CodeGenerator.generateNestedFunctions(CodeGenerator.java:210) at org.mozilla.javascript.CodeGenerator.generateICodeFromTree(CodeGenerator.java:124) at org.mozilla.javascript.CodeGenerator.generateFunctionICode(CodeGenerator.java:120) at org.mozilla.javascript.CodeGenerator.generateNestedFunctions(CodeGenerator.java:211) at org.mozilla.javascript.CodeGenerator.generateICodeFromTree(CodeGenerator.java:124) at org.mozilla.javascript.CodeGenerator.compile(CodeGenerator.java:92) at org.mozilla.javascript.Interpreter.compile(Interpreter.java:396) at org.mozilla.javascript.Context.compileImpl(Context.java:2448) at org.mozilla.javascript.Context.compileReader(Context.java:1358) at org.mozilla.javascript.commonjs.module.provider.CachingModuleScriptProviderBase.getModuleScript(CachingModuleScriptProviderBase.java:93) at org.mozilla.javascript.commonjs.module.provider.SoftCachingModuleScriptProvider.getModuleScript(SoftCachingModuleScriptProvider.java:59) at org.mozilla.javascript.commonjs.module.Require.getModule(Require.java:350) at org.mozilla.javascript.commonjs.module.Require.getExportedModuleInterface(Require.java:258) at org.mozilla.javascript.commonjs.module.Require.call(Require.java:215) at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1869) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:1051) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:87) at org.mozilla.javascript.ArrowFunction.call(ArrowFunction.java:40) at org.mozilla.javascript.NativeArray.iterativeMethod(NativeArray.java:2031) at org.mozilla.javascript.NativeArray.execIdCall(NativeArray.java:437) at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:84) at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1869) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:1051) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:87) at org.mozilla.javascript.ArrowFunction.call(ArrowFunction.java:40) at org.mozilla.javascript.NativeArray.iterativeMethod(NativeArray.java:2031) at org.mozilla.javascript.NativeArray.execIdCall(NativeArray.java:437) at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:84) at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1869) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:1051) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:87) at org.mozilla.javascript.ArrowFunction.call(ArrowFunction.java:40) at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1869) at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:1051) at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:87) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:383) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3941) at org.mozilla.javascript.Context.callFunctionWithContinuations(Context.java:1253) at org.mozilla.javascript.Context.executeScriptWithContinuations(Context.java:1221) at org.autojs.autojs.engine.RhinoJavaScriptEngine.init(RhinoJavaScriptEngine.kt:110) at org.autojs.autojs.engine.LoopBasedJavaScriptEngine.init(LoopBasedJavaScriptEngine.java:101) at org.autojs.autojs.execution.RunnableScriptExecution.prepare(RunnableScriptExecution.java:65) at org.autojs.autojs.execution.RunnableScriptExecution.execute(RunnableScriptExecution.java:39) at org.autojs.autojs.execution.RunnableScriptExecution.execute(RunnableScriptExecution.java:34) at org.autojs.autojs.execution.RunnableScriptExecution.run(RunnableScriptExecution.java:28) at java.lang.Thread.run(Thread.java:1012)

nsy9601 commented 8 months ago

补充:出这个错的时候,任务时运行中的任务存在且无法结束,需要重启autojs应用

SuperMonster003 commented 8 months ago

依然是类似 https://github.com/SuperMonster003/AutoJs6/issues/148 的问题.

一般是图像相关的代码容易导致 OOM.

最好能提供一下导致上述异常的代码片段.

wingswing1 commented 8 months ago

依然是类似 #148 的问题.

一般是图像相关的代码容易导致 OOM.

最好能提供一下导致上述异常的代码片段.

我没有图片处理,我是多脚本运行时,相关代码如下(可能不是这段引起的): while(engines.all().length>=2&&j<120){ j++; sleep(1000); if(j==119){ log(scriptFiles[i]+"运行超时,请检查!"); var test=engines.all(); for(k=0;k<test.length;k++){ var str=String(test[k].getSource()); if(str==path){ test[k].forceStop(); toastLog("已停止"+str); } } } }

hduwhyso commented 8 months ago

我猜测是你用了aj封装的线程引起的,换成java的线程试试

wingswing1 commented 8 months ago

我猜测是你用了aj封装的线程引起的,换成java的线程试试

这个脚本我用了一两年了,从autoxjs转autojs6,好像autojs6最近崩溃的有点儿多(xjs也有崩溃) 这就是个签到脚本,应该不算多线程吧??另外我也不会JAVA

hduwhyso commented 8 months ago

我猜测是你用了aj封装的线程引起的,换成java的线程试试

这个脚本我用了一两年了,从autoxjs转autojs6,好像autojs6最近崩溃的有点儿多(xjs也有崩溃) 这就是个签到脚本,应该不算多线程吧??另外我也不会JAVA

你的代码里有没有这个 threads.start(function(){ //在新线程执行的代码 });

wingswing1 commented 8 months ago

没有

---- 回复的原邮件 ---- | 发件人 | @.> | | 日期 | 2023年11月07日 10:31 | | 收件人 | @.> | | 抄送至 | @.>@.> | | 主题 | Re: [SuperMonster003/AutoJs6] 报错,版本v6.4.1,这种报错常出 (Issue #165) |

我猜测是你用了aj封装的线程引起的,换成java的线程试试

这个脚本我用了一两年了,从autoxjs转autojs6,好像autojs6最近崩溃的有点儿多(xjs也有崩溃) 这就是个签到脚本,应该不算多线程吧??另外我也不会JAVA

你的代码里有没有这个 threads.start(function(){ //在新线程执行的代码 });

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

TKWei commented 7 months ago

for循环里加sleep(1000)等待,可能循环太快了。