SuperMonster003 / AutoJs6

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

java.lang.OutOfMemoryError 报错内存溢出 #200

Open 239144498 opened 12 months ago

239144498 commented 12 months ago

因为程序用到了多线程截图找色,所以每次找色都会用到Images.copy,在执行完后都会手动回收,但是这个6.5.0最新版好像并没有回收,当我多次重复停止-启动就会报下面的错误,我每次使用完copy方法都有recycle,不知道是哪里出的问题。

Failed to allocate a 8294412 byte allocation with 5472624 free bytes and 5MB until OOM

java.lang.OutOfMemoryError: Failed to allocate a 8294412 byte allocation with 5472624 free bytes and 5MB until OOM
    at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
    at android.graphics.Bitmap.nativeCopy(Native Method)
    at android.graphics.Bitmap.copy(Bitmap.java:592)
    at org.autojs.autojs.core.image.ImageWrapper.clone(ImageWrapper.kt:146)
    at org.autojs.autojs.runtime.api.Images.copy(Images.java:130)
    at java.lang.reflect.Method.invoke(Native Method)
    at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:216)
    at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:211)
    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.InterpretedFunction.exec(InterpretedFunction.java:100)
    at org.autojs.autojs.engine.RhinoJavaScriptEngine.doExecution(RhinoJavaScriptEngine.kt:71)
    at org.autojs.autojs.engine.JavaScriptEngine.execute(JavaScriptEngine.java:24)
    at org.autojs.autojs.engine.LoopBasedJavaScriptEngine.access$001(LoopBasedJavaScriptEngine.java:19)
    at org.autojs.autojs.engine.LoopBasedJavaScriptEngine.lambda$execute$0(LoopBasedJavaScriptEngine.java:45)
    at org.autojs.autojs.engine.LoopBasedJavaScriptEngine.$r8$lambda$I-xFIUoHN3n1hvGjYIMvKioppEM(LoopBasedJavaScriptEngine.java)
    at org.autojs.autojs.engine.LoopBasedJavaScriptEngine$$ExternalSyntheticLambda0.run(D8$$SyntheticClass)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at org.autojs.autojs.engine.LoopBasedJavaScriptEngine.execute(LoopBasedJavaScriptEngine.java:68)
    at org.autojs.autojs.engine.LoopBasedJavaScriptEngine.execute(LoopBasedJavaScriptEngine.java:38)
    at org.autojs.autojs.execution.LoopedBasedJavaScriptExecution.doExecution(LoopedBasedJavaScriptExecution.java:45)
    at org.autojs.autojs.execution.RunnableScriptExecution.execute(RunnableScriptExecution.java:40)
    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:761)
EvenToss commented 11 months ago

找到问题了吗?我也遇到了

670027822 commented 3 weeks ago

挖槽,这个问题急需解决