Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump the memory at different stages of activities lifecycle without changing the test itself, #2525

Open
mohamadk opened this issue May 31, 2023 · 1 comment

Comments

@mohamadk
Copy link
Contributor

If these assumptions are correct
You can dump the memory at any time in the main thread in the app (this might cause the OS to show the app not responding dialog)
the stage where you dump memory is critical to find the leaks,

what I wanted to do is, in UI tests, dump the memory at different stages of activities lifecycle without changing the test itself,
to achieve this, I can add a lifecycle listener to the app in AndroidJUnitRunner and ask for heap dump whenever an activity goes to resume step or destroy step, etc.

At the end of the UI test ill check all heap files and look for leaks.

what do you think?

@pyricau
Copy link
Member

pyricau commented Jun 1, 2023

It's a great idea! I have tried doing similar where I check for leaks every time we use Espresso to check for views (we have a thin API wrapper on top of Espresso so I could insert my code there). This worked but slowed down the tests quite a bit, and also it found so many leaks that I need to fix those leaks before I merge that change in our codebase. But anyway, yes, you should definitely try this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants