'How in Flutter do I pinpoint a potential memory issue when it crashes and DevTools disappears?

I have an app that loads videos from urls and the assets folder.

A single screen may have seven videos in memory all at once.

I'm using the Video Player library (https://pub.dev/packages/video_player)

When I exit the screen I override dispose and dispose of every video controller.

When I navigation between screens with videos the app eventually crashes. It simply says Lost Connection to Device.

I ran the app through Xcode because Xcode can tell me something useful to go on. As I was expecting, the app is crashing from memory pressure.

Unfortunately, due to how Flutter is built I can't run the app through Instruments and I have to rely on DevTools. DevTools doesn't stay around when an app crashes, so it's impossible to see any memory issues it might be trying to tell me.

How can I debug memory pressure in Flutter if there's no profiling tools that can help?



Solution 1:[1]

What I suggest that you do is to run your app in Xcode and then open Instruments separately and attach it to your application process. That way you should be able to see what is causing the memory hog.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vandad Nahavandipoor