fix: Purge cache on memory warning to prevent OOM crashes#3711
fix: Purge cache on memory warning to prevent OOM crashes#3711mrousavy wants to merge 1 commit intoShopify:mainfrom
Conversation
|
The reason why memory grows so rapidly is because of the same problem I highlighted in #3704 - And But on any Long story short; as a follow-up PR we should eventually go away from caching This is the original PR I had up 2 years ago to fix this same |
|
Great find on the cache purge, flutter does exactly the same thing: |
|
I understand the issue. Because you use a thread pool, the current way the Dispatcher work, it will never work as expected in this particular context. |
|
Yep! Pretty much. I don't explicitly use a Thread Pool though, this is just how GCD / My suggestion is to maybe cache everything per JS Runtime instead ( |
Purges the Skia cache (including unused GPU textures), as well as the Metal Texture Pool (used for VisionCamera/NativeBuffer APIs) when we receive a memory warning from iOS.
Before
The app crashes after ~5-10 seconds when stress testing Skia VisionCamera with 4k YUV 4:2:2 10-bit buffers, about the 3GB RAM mark:
After
The app runs fine, and purges the Skia/Metal GPU cache when it hits ~3GB RAM:
Individual purges
You can see the individual cache purges here:
