sutAgent should handle onLowMemory

RESOLVED FIXED in mozilla17

Status

Testing Graveyard
SUTAgent
RESOLVED FIXED
6 years ago
4 months ago

People

(Reporter: gbrown, Assigned: gbrown)

Tracking

unspecified
mozilla17
x86
Android

Details

Attachments

(1 attachment)

sutAgent should have an onLowMemory handler. The primary motivation for this would be to log diagnostics to record that the system is running low on memory and is starting to kill off processes. Logging to logcat might be useful when running sutAgent locally/debugging; also logging to the new sutcommands.txt file might be more useful for production.

It might also be possible to clean up some unused resources at this time, to improve the chances of sutAgent surviving low memory conditions.

-----------

From Android docs for Activity class:

public void onLowMemory ()
Since: API Level 1

This is called when the overall system is running low on memory, and would like actively running process to try to tighten their belt. While the exact point at which this will be called is not defined, generally it will happen around the time all background process have been killed, that is before reaching the point of killing processes hosting service and foreground UI that we would like to avoid killing.

Applications that want to be nice can implement this method to release any caches or other unnecessary resources they may be holding on to. The system will perform a gc for you after returning from this method.
Created attachment 647353 [details] [diff] [review]
handle onLowMemory in sutagent; log memory info

Building on the patch for 778784, this patch handles onLowMemory by logging to our sutcommands.txt file. 

This patch also tries to log system memory info and process memory info for any process with "mozilla" in its process name. I am a little uneasy about this part in that we are using additional memory in onLowMemory, but I have tried to mitigate this by being extra careful about failed allocations.

It seems to work - here is output from a mochitest-3 run:

2012/07/30 05:30:18:209 : 192.168.0.86 : pull /mnt/sdcard/tests/logs/mochitest.log
2012/07/30 05:30:18:329 : 192.168.0.86 : hash /mnt/sdcard/tests/logs/mochitest.log
2012/07/30 05:30:20:174 : onLowMemory
2012/07/30 05:30:21:145 : PA:76255232, FREE: 20299776
2012/07/30 05:30:21:174 : 10085 9035    org.mozilla.fennec_mozdev
2012/07/30 05:30:21:180 : Dalvik Private Dirty pages         3052 kb
Dalvik Proportional Set Size       4034 kb
Dalvik Shared Dirty pages          4140 kb

Native Private Dirty pages heap    3464 kb
Native Proportional Set Size heap  3573 kb
Native Shared Dirty pages heap     1364 kb

Other Private Dirty pages          130084 kb
Other Proportional Set Size        163498 kb
Other Shared Dirty pages           4948 kb

Total Private Dirty Memory         136600 kb
Total Proportional Set Size Memory 171105 kb
Total Shared Dirty Memory          10452 kb
2012/07/30 05:30:21:299 : 10082 9013    com.mozilla.SUTAgentAndroid
2012/07/30 05:30:21:303 : Dalvik Private Dirty pages         888 kb
Dalvik Proportional Set Size       1307 kb
Dalvik Shared Dirty pages          4192 kb

Native Private Dirty pages heap    1068 kb
Native Proportional Set Size heap  1192 kb
Native Shared Dirty pages heap     1480 kb

Other Private Dirty pages          1172 kb
Other Proportional Set Size        2066 kb
Other Shared Dirty pages           1448 kb

Total Private Dirty Memory         3128 kb
Total Proportional Set Size Memory 4565 kb
Total Shared Dirty Memory          7120 kb
2012/07/30 05:30:23:470 : 192.168.0.86 : ps
2012/07/30 05:30:23:525 : 192.168.0.86 : pull /mnt/sdcard/tests/logs/mochitest.log
2012/07/30 05:30:23:622 : 192.168.0.86 : hash /mnt/sdcard/tests/logs/mochitest.log


I could not find/think of any good candidates for deletion in onLowMemory; we can keep that in mind for a future patch.
Attachment #647353 - Flags: review?(jmaher)
Comment on attachment 647353 [details] [diff] [review]
handle onLowMemory in sutagent; log memory info

Review of attachment 647353 [details] [diff] [review]:
-----------------------------------------------------------------

this is great stuff.  You don't have to register a listener for OnLowMemory, it just magically calls this function?  Otherwise I like how it logs the memory and processes.
Attachment #647353 - Flags: review?(jmaher) → review+
(In reply to Joel Maher (:jmaher) from comment #2)
> You don't have to register a listener for OnLowMemory,
> it just magically calls this function? 

That's right: no listener registration is required / it is just a method override in the Activity class (aka "magic").
https://hg.mozilla.org/mozilla-central/rev/5341c82747b3
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla17

Updated

4 months ago
Product: Testing → Testing Graveyard
You need to log in before you can comment on or make changes to this bug.