RobotiumTech / robotium

Android UI Testing
http://www.robotium.org
Apache License 2.0
2.86k stars 786 forks source link

"activityMonitorThread" thread leak -> activity leak -> OOM. #795

Closed enikey87 closed 9 years ago

enikey87 commented 9 years ago

Solo.finishOpenedActivities() doesn't correctly shutdown "activityMonitorThread".

This thread can prevent activities from being garbage collected causing OOM during large number of test execution (it can be reason of https://github.com/RobotiumTech/robotium/issues/706).

Thread hang caused by waitForActivity() call, that could wait forever cause of following execution chain:

...

ActivityMonitorThread will wait forever preventing last activity it saw from being collected.

P.S. Execution chain can be different cause I didn't run & debug it, but hang & leak caused by it is fact.

renas commented 9 years ago

Thanks for reporting this.

On Sun, Nov 8, 2015 at 11:47 PM, enikey87 notifications@github.com wrote:

Solo.finishOpenedActivities() doesn't correctly shutdown "activityMonitorThread".

This thread can prevent activities from being garbage collected causing OOM during large number of test execution (it can be reason of #706 https://github.com/RobotiumTech/robotium/issues/706).

Thread hang caused by waitForActivity() call, that could wait forever cause of following execution chain: [InstrumentationThread]: finishOpenedActivities() -> finish activities ...

[ActivityMonitorThread]:

  • waitForActivity() returns.
  • waitForActivity() blocks cause interruption flag still not set. [InstrumentationThread]: interruption flag for ActivityMonitorThread = true. ... blabla. finishOpenedActivities() returns.

...

ActivityMonitorThread will wait forever preventing last activity it saw from being collected.

— Reply to this email directly or view it on GitHub https://github.com/RobotiumTech/robotium/issues/795.