Closed GoogleCodeExporter closed 9 years ago
Thanks for reporting this. Would it be possible for you to send me a sample app
that exhibits this problem?
Original comment by renasr...@gmail.com
on 25 Sep 2012 at 5:52
I'm using robotium 3.3, and I think it exists for all applications. Here's how
to observe it:
1. Create a HelloWorld Android application in Eclipse.
2. Create an Android test project for it, and set up the following test case:
while (true) {
solo.setActivityOrientation(Solo.LANDSCAPE);
solo.sleep(2000);
solo.setActivityOrientation(Solo.PORTRAIT);
solo.sleep(2000);
}
3. Open DDMS to observe the Java heap size. You will see it increasing *very*
slowly. After a few minutes, you can do a hprof dump and see there are a lot of
instances of WeakReference. Then, if you inspect the incoming references to
these WeakReference objects, you can see they are ultimately referenced by
ActivityUtils.activityStack.
I think the problem is that ActivityUtils.activityStack does not mimic the real
activity stack. Instead, the top few elements of ActivityUtils.activityStack
sort of reflect the current activity stack.
Original comment by tonywins...@gmail.com
on 25 Sep 2012 at 6:21
This issue existed on 3.3 but has been fixed in 3.4.1. Please try with the
latest version instead.
Original comment by renasr...@gmail.com
on 25 Sep 2012 at 6:23
I just tried it, and the problem still exists. Can you point me to the code
diffs that fix this problem?
Original comment by tonywins...@gmail.com
on 25 Sep 2012 at 6:49
Before 3.4.1 there were still strong references to activities even after the
weak reference objects had been created. That is not the case anymore. Now only
weak references are kept and they are not responsible for keeping activities
alive. This improvement has been confirmed by several people that had memory
issues prior to 3.4.1.
Have you analyzed the memory footprint of your application when doing rotation
changes manually?
Original comment by renasr...@gmail.com
on 25 Sep 2012 at 7:15
I'm NOT saying Activity instances are kept alive. It is the WeakReference
instances that are kept alive. And of course, the String instances in
activitiesStoredInActivityStack are also alive. Once they are added to the
stack, they are never removed. I confirmed this using MAT to analyse the heap
dump. You can do the same in 10 minutes if you are willing to.
If I don't use robotium, the problem does not exist.
Original comment by tonywins...@gmail.com
on 25 Sep 2012 at 7:21
Ok, now I understand what you mean. This will be looked at and improved in the
next release. I will let you know when the changes have been made so you can
verify that the issue does not exist anymore.
Original comment by renasr...@gmail.com
on 25 Sep 2012 at 7:24
Thanks again. The leak in activityStack has been fixed in Robotium 3.5.
Original comment by renasr...@gmail.com
on 11 Oct 2012 at 5:12
Original issue reported on code.google.com by
tonywins...@gmail.com
on 23 Sep 2012 at 2:45