element-hq / element-hq/element-ios

Share extension: Improve memory usage to avoid force quit due to memory limit exception

Open
#2,341 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Swift
Stars
1.8k
Forks
544
PR merge metrics
PR metrics pending

Description

A share extension can use a limited quantity of RAM and if it goes over this limit (for example 120mb on an iPhone X on iOS 12), a memory limit exception is thrown (`EXC_RESOURCE RESOURCE_TYPE_MEMORY`) that causes share extension to force quit.

Currently this exception happens most often when sharing several images or a large image like a panorama.

Another observed problem is that memory seems to not be freed when the share extension is closed and then relaunched some time later.

In order to reduce memory usage here is a list of actions that can be performed:

- Try to load the less data as possible from the `MXStore` in memory (do not load useless data such as read receipts for example).
- Write incoming data to disk rather than keeping them in memory.
- For image resizing, limit the large output image size of panorama.
- Track other possible memory issues like:
- Memory leaks
- Retain cycles
- Shared instances loaded unnecessarily

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.