Closed Bug 1686100 Opened 5 years ago Closed 5 years ago

Route Service.onTrimMemory notifications through to Gecko's memory pressure observer

Categories

(GeckoView :: General, enhancement, P1)

All
Android
enhancement

Tracking

(firefox86 fixed)

RESOLVED FIXED
86 Branch
Tracking Status
firefox86 --- fixed

People

(Reporter: bugzilla, Assigned: bugzilla)

References

Details

(Whiteboard: [geckoview:m87])

Attachments

(2 files)

Since Android may send these to the services hosting content processes, we should route them through to the memory-pressure observer, which will help by forcing GCs, cleaning up the heap, etc.

I don't expect this to be a definitive fix for bug 1682319, but it should help.

Whiteboard: [geckoview:m87]

Gecko already broadcasts memory-pressure events from the parent process down
to its content processes, but that excludes any case where Android is calling
Service.onTrimMemory directly on the content processes.

This patch handles onTrimMemory and translates its requests into
memory-pressure events that various Gecko components (including the GC)
listen for. We only handle the severity levels for background processes for now,
as memory cleanup for background processes is currently the most pressing issue
(and I'm not even sure what we could do for foreground memory cleanup without
janking anything).

The argument to memory-pressure should depend on the severity of the request
as well as the frequency of pressure events. In particular:

  • The most severe request, TRIM_MEMORY_COMPLETE, is a last-ditch effort to
    reduce memory. This should trigger a full GC, so we use low-memory here.
  • "New" requests, where "new" is defined as an event that was triggered in
    excess 10 seconds since the previous "new" event, also gets a full GC, so we
    use low-memory here as well.
  • Additional requests that do not fall under either of the above criteria
    receive the low-memory-ongoing event, which omits a full GC. The idea here
    is that, when low memory notifications occur in rapid succession, repeatedly
    doing full GCs over and over is just going to hang the Gecko thread and not
    result in any notable improvement.
Pushed by aklotz@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/cddfeeb87193 Route Service.onTrimMemory notifications through to Gecko's memory-pressure observer; r=geckoview-reviewers,agi
Pushed by btara@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1dc8d0dd5e30 Follow-up to fix lint failure; r=bustage
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 86 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: