kkevsekk1 / AutoX

A UiAutomator on android, does not need root access(安卓平台上的JavaScript自动化工具)
Other
7.43k stars 1.77k forks source link

Error memory long time run #1078

Open tuanmjnhdeveloper opened 1 month ago

tuanmjnhdeveloper commented 1 month ago
  1. Autox.js 版本:664
  2. Autox.js 下载渠道:https://github.com/kkevsekk1/AutoX/releases
  3. Android 版本:Android 10
  4. Android 机型:小米10
  5. Android 系统类别:MIUI
  6. VSCODE 扩展版本 Auto.js-Autox.js-VSCodeExt (可选,如果是连接电脑的问题需要填):
  7. 问题描述:
  8. 报错日志(可选):
  9. 屏幕截图(可选):

error When I run for a long time this error appears. Please help me fix this part.

Liberations commented 1 month ago

Need more information, such as sample code. Also, pay attention to the recycling of some image resources in your code.

tuanmjnhdeveloper commented 1 month ago

Need more information, such as sample code. Also, pay attention to the recycling of some image resources in your code.

function onReStart() { indexBot = 0; repeat++; utils.shuffle(bots); window.autoBot.RepeatTime.setText(repeat + ""); // log(Repeat: ${repeat}); toast(Repeat: ${repeat}); if (utils.isRooted()) { utils.forceStopAppRootAccess("org.telegram.messenger"); sleep(3000); } else { utils.forceStopApp("org.telegram.messenger"); sleep(6000); } onStart(); }

// var threadsDisposable = threads.disposable(); var threadsStartMain = null; var threadsStartFile = null; var scriptFile = null; var execFile = null; var engine = null;

function onStart() { if (bots.length < 1) { toast("No bot to run!") return; } isAutoBot = true; threadsStartMain = threads.start(() => { try { sleep(2000); while (isAutoBot) { scriptFile = files.join(bots[indexBot].p, bots[indexBot].k); // log(Running: ${file}`) sleep(1000); threadsStartFile = threads.start(() => { execFile = engines.execScriptFile(scriptFile);//,{ delay: 5000, interval:, loopTimes: 0 } }); sleep(3000);

    // isDestroyed = utils.isDestroyedEngine(engine, 5000);
    while (true) {
      sleep(2000);
      engine = execFile.getEngine();
      // console.log(engine);
      // console.log(engine.toString());
      // console.log(engines.all());
      // console.log(thread);
      // console.log(threadStart.isAlive());
      if (engine.isDestroyed()) {
        threadsStartFile.interrupt();
        engine.forceStop();
        engine = null;
        execFile = null;
        scriptFile = null;
        // console.log(thread.isAlive());
        java.lang.System.gc();
        break;
      }
    } // Check every second if the script is done

    indexBot++;
    if (indexBot >= bots.length) {
      // indexBot = 0;
      // repeat++;
      // utils.shuffle(bots);
      // window.autoBot.RepeatTime.setText(repeat + "");
      // // log(`Repeat: ${repeat}`);
      // toast(`Repeat: ${repeat}`);
      // sleep(2000);
      onReStart();
      console.log("restart");
      break;
    }
  };
} catch (error) {
  console.log(error);
  // alert("error", error);
  files.write(utils.logsMainPath, error);
}

}); }; floatyWindow.zip

I not use findColor or findImage function. I just use find text for all automation. I used global variable but still got error after about 30 to 40 minutes of running. Please help me!

Liberations commented 1 month ago

You can write a simple and runnable demo and push it on GitHub. I can't check this now

tuanmjnhdeveloper commented 1 month ago

You can write a simple and runnable demo and push it on GitHub. I can't check this now

https://github.com/tuanmjnhdeveloper/autoxjs-demo

i think error in "execScriptFile", Maybe this function loads the script file and executes the command, but when it finishes, it doesn't release memory.

I done it. Please check for me. Thank you so much!

Liberations commented 1 month ago

You can write a simple and runnable demo and push it on GitHub. I can't check this now

https://github.com/tuanmjnhdeveloper/autoxjs-demo

i think error in "execScriptFile", Maybe this function loads the script file and executes the command, but when it finishes, it doesn't release memory.

I done it. Please check for me. Thank you so much!

utils.js Method missing, unable to reproduce oom exception, please provide a simpler demo.

tuanmjnhdeveloper commented 1 month ago

You can write a simple and runnable demo and push it on GitHub. I can't check this now

https://github.com/tuanmjnhdeveloper/autoxjs-demo i think error in "execScriptFile", Maybe this function loads the script file and executes the command, but when it finishes, it doesn't release memory. I done it. Please check for me. Thank you so much!

utils.js Method missing, unable to reproduce oom exception, please provide a simpler demo.

that i call libaray. you can run in Emulator app Autox.js, dont run in visual code. i was make a simple demo bro. plase check again it. Thank you so much