mobile-dev-inc / maestro

Painless Mobile UI Automation
https://maestro.mobile.dev/
Apache License 2.0
5.69k stars 260 forks source link

Very high memory usage with Maestro Studio on Linux #1087

Open meatnordrink opened 1 year ago

meatnordrink commented 1 year ago

Describe the bug Memory use on Linux increases dramatically when using Maestro Studio - it will slowly and steadily increase from a baseline of about 44% (of 32G) until the computer crashes. Closing Maestro Studio immediately reduces memory usage back to ~44%. (The tests finishing does not affect memory usage.)

It appears that this happens when Maestro Studio is running while a Maestro test on the device it is observing is running, even if Maestro Studio itself is not being interacted with.

To Reproduce

(On Linux) Launch an emulator with an app built. Launch Maestro Studio - maestro studio. Run a few long Maestro tests. Watch your memory use increase.

Expected behavior

Memory use to increase slightly, due to Maestro Studio running, but then remain steady.

Environment information (please complete the following information):

Workspace (if applicable) I can't share the application code, nor is the issue really about a Maestro test, but if there's specific information you need let me know and I'll do my best.

meatnordrink commented 10 months ago

A further note on this - on Linux, killing Maestro Studio in one terminal with ctrl + c also kills any simultaneously-running Maestro test.

I thought this was universal behavior, but I just now realized this isn't the case on iOS - and so wondered if it might be connected to the memory leak bug. (Which is still very much happening - Maestro Studio is only usabel for about ~7min on Linux.)

synapticvoid commented 5 months ago

I have the same issue with the latest version of Maestro.

scriptas commented 4 months ago

I run maestro tests from a raspberry, so this high memory usage is a massive issue. It completely freezes a (32gb sd card) raspberry pi in around 20 hours.

Restarting RPi works, but just for around 24 hours.

After investigating, I found that ./tmp folder is getting jammed up by hundreds of maestro-app.apk & maestro-server.apk files. Deleting those will clear up the memory.

As a temporary fix, I will just involve a cleanup of those files into a test as a solution.

bartekpacia commented 1 month ago

Hey @scriptas – do you mean that you use Maestro Studio, or just run tests with maestro test on your Raspberry Pi? Also, thanks for sharing the findings with us.

scriptas commented 1 month ago

@bartekpacia I use raspberry to run the tests. I do not use the maestro studio.

And that fix I've suggested to remove temp files has now been working very well for me for the last 6 months. Raspberry is no longer freezing, and seems like no important data related to the test logs is actually being deleted.