Skip to content

Memory pressure handling #350

Open
Open
@buttercookie42

Description

@buttercookie42

If Android claims memory pressure, it's probably better if we try to free some memory ourselves instead of subsequently being killed completely stone dead by the OOM killer.
Apart from various memory caches we might use, the biggest memory savings can probably be made by unloading background tabs.

For Fennec, we've been tracking Android's memory pressure messages and mapping them to our own internal memory pressure levels. Because Android also doesn't notify you when memory-pressure is over, we assume that if we receive no new events for a few minutes, we can drop our internal memory pressure level by one step.

Fennec currently drops all background tabs (except those that are playing audio!, and tabs using web sockets or something like that were also a wishlist item if I remember correctly) when our internal memory pressure is at least MEDIUM, but it might be worth trying a more gradual approach, i.e. discard a few tabs (sorted by least recently used) and then progressively discard more tabs if Android continues signalling memory pressure.

Another thing to note is that memory pressure (as well as the end of memory pressure) should also be forwarded to Gecko, so that Gecko can e.g. clean up its caches as well (e.g. the image cache).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions