Skip to content

Crashes due to aggressive RAM usage on old devices #849

@marcgeeklaberge

Description

@marcgeeklaberge

Hi y'all, we've recently run into some Crashed issues. These issues were mainly due to low user RAM being available.
From this code, we noticed that you guys set a limit of 512MB for usage before you start to automatically clean the usage.

For some devices, this is not an issue, and this limit could be way higher. But we observed that this could be an issue for older devices (like the iPhone X or older) which have <= 100MB of available RAM. We think this is the cause of these crashes (we're not sure how the OS lets this happen, honestly).

Meanwhile, I'm wondering if you would be open to working on an improvement to make this more dynamic, which means looking at how much available RAM the user has. We still want to be able to set a higher limit for devices that have the memory available, but we would like to reduce crashes on devices with low RAM.

public static func defaultCostLimit() -> Int {
let physicalMemory = ProcessInfo.processInfo.physicalMemory
let ratio = physicalMemory <= (536_870_912 /* 512 Mb */) ? 0.1 : 0.2
let limit = min(536_870_912, physicalMemory / UInt64(1 / ratio))
return Int(limit)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions