scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

Windows goes to sleep causing Android machine memory to increase

Open erd-yunmu opened this issue 1 year ago • 9 comments

  • [x] I have read the FAQ.
  • [x] I have searched in existing issues.

Environment

  • OS: Windows
  • scrcpy version: 2.4
  • installation method: Windows exe
  • device model:rk3588
  • Android version: Android12、Android13

Describe the bug I am using Windows to interact with rk3588 development and found that the memory usage is increased Causes the memory to be full, terminating all running background programs I think it may be caused by the data packet not being released.

Here is how I tested Reappear soon:First open scrcpy and enter the desktop, then open the system camera --->stand still,Next, put your computer Windows into sleep mode. Select Sleep on the power button in the lower left corner of Windows and wait for 1 minute before waking up. Then open adb shell and execute top to find that the memory usage is more than 80%. As shown clipboard-202406251339-poymy image

I am using 16GB of RAM I have tried Android 12 and Android 13 and both have this problem This happens only when the computer is shut down after sleeping and the adb connection is disconnected. I have also tried disconnecting the adb cable and this does not happen.

Normal memory is as shown in the figure image

I have finished talking about the above questions. If you need testing, I am willing to test the software for you. Thank you!

erd-yunmu avatar Jun 25 '24 07:06 erd-yunmu

I used this software and it did not increase the memory capacity. https://www.vysor.io/

erd-yunmu avatar Jun 25 '24 07:06 erd-yunmu

Thank you for the report.

Given the description, it looks like the device buffers input data indefinitely if it is not consumed by the client (applying a backpressure). But if I "freeze" (Ctrl+z on Linux) the client process, I cannot reproduce on my device.

First open scrcpy and enter the desktop, then open the system camera --->stand still,Next, put your computer Windows into sleep mode.

I fail to reproduce: when I put a Windows into sleep mode, when I wake it up, scrcpy is disconnected (the adb socket is closed probably).

Can you reproduce with a different device (other than rk3588)?

Does it also happen with another encoder?

rom1v avatar Jun 25 '24 08:06 rom1v

Also, does it happen if you capture the camera directly (instead of mirroring the screen and opening the camera app)?

scrcpy --video-source=camera

rom1v avatar Jun 25 '24 08:06 rom1v

Sorry, I didn't make that clear.

First open scrcpy and enter the desktop, then open the system camera --->stand still,Next, put your computer Windows into sleep mode.

  1. Open scrcpy software in Windows
  2. Use the mouse to open the system camera on the scrcpy desktop
  3. Put the computer to sleep
  4. Wait for 1 minute
  5. Wake up the Windows computer again
  6. Use adb to connect to the Android device and execute top to check the memory usage to see if it has increased This is how I did it, please try again

erd-yunmu avatar Jun 25 '24 08:06 erd-yunmu

Use the mouse to open the system camera on the scrcpy desktop

You mean opening the camera app on Android while scrcpy is running, is that correct? (clicking via scrcpy or not is irrelevant, it is opened on the device anyway)

Use adb to connect to the Android device and execute top to check the memory usage to see if it has increased This is how I did it, please try again

I tried again, and when I wake up, memory usage on Android is normal (and also scrcpy is closed on wake up). But this is not the same device as yours.

rom1v avatar Jun 25 '24 08:06 rom1v

My Xiaomi phone 12GB also has a similar situation, which does cause the memory to increase image For Xiaomi, I do this: I use scrcpy on the computer to open the Xiaomi 12 mobile phone camera, and then the computer goes to sleep. At this time, the mobile phone camera is always open and not closed. The memory starts to increase slowly. It is recommended to wait 1-2 minutes before waking up the computer during sleep, open adb shell and execute top to find that the memory is occupied a lot.

erd-yunmu avatar Jun 25 '24 09:06 erd-yunmu

In adb shell, run top with these arguments:

top -o PID,USER,CMDLINE,%MEM

It will list the process sorted by memory usage.

rom1v avatar Jun 25 '24 09:06 rom1v

image It seems that the application does not take up memory

erd-yunmu avatar Jun 25 '24 09:06 erd-yunmu

hi is there any solution? If I haven't explained it clearly, we can contact you via Google chat and I will tell you the steps to reproduce the problem.

erd-yunmu avatar Jun 27 '24 03:06 erd-yunmu