appium / java-client

Java language binding for writing Appium Tests, conforms to W3C WebDriver Protocol
Apache License 2.0
1.21k stars 756 forks source link

Appium java-client 8.6.0 caused a memory leak #2038

Closed olezvinskyi closed 11 months ago

olezvinskyi commented 12 months ago

Description

After I updated java-client 8.5.0 -> 8.6.0 I started facing memory lek (java.lang.OutOfMemoryError: Java heap space). I have a daily suite with a large number of tests (389 tests) and usually, it takes 3-4 hours to complete. In the previous version, everything worked fine but with 8.6.0 after 175-189 tests I got an exception about a memory leak.

Environment

Details

Java: 15 and 17 Gradle: 8.2.1 Selenide: 6.19.0 (which uses the latest appium java-client)

Code To Reproduce Issue [ Good To Have ]

Code

Exception Stacktraces

Exception

Link To Appium Logs

Appium Logs

mykola-mokhnach commented 12 months ago

Consider calling initElements once on page creation. I don't think it is a good idea to do it multiple times. I also need a heap dump

olezvinskyi commented 12 months ago

Consider calling initElements once on page creation. I don't think it is a good idea to do it multiple times. I also need a heap dump

I rerun my tests to generate a new heap dump and I will upload it here. But for now, I can attach a heap dump from old test run https://drive.google.com/file/d/1z30BIFhPi1de648FuCce5ElH90utuENs/view?usp=sharing

mykola-mokhnach commented 12 months ago

I have checked the above heap dump, and it looks fine to me. Nothing too suspicious. Try to get the dump when it actually crashes or close to it (You could use the https://www.baeldung.com/java-heap-dump-capture#automatically)

olezvinskyi commented 11 months ago

@mykola-mokhnach https://drive.google.com/file/d/1-Y-AZKdqjAC8G3HPU1-7I1Vc0yIGgspJ/view?usp=sharing fresh heap dump

mykola-mokhnach commented 11 months ago
olezvinskyi commented 11 months ago


- We call initElements once we open a new page and create an instance of this page. 

But in 8.5.0 everything worked fine. 
mykola-mokhnach commented 11 months ago

I assume it might be some specific to your project setup. Try to profile it and check what data structures are using the most of the memory. Maybe I would be able to help when/if I know for sure which entities they reference and why, and if these entries are part of this library.

olezvinskyi commented 11 months ago

I removed PageFactory (initElements) approach and integrated Selenide into my framework. So for now I don't see java.lang.OutOfMemoryError