V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
murmurkerman
V2EX  ›  Android

如何 Flutter Release 环境中诊断 OOM

  •  
  •   murmurkerman · Dec 25, 2024 · 4841 views
    This topic created in 500 days ago, the information mentioned may be changed or developed.

    大家怎么诊断在 release 商店包中出现的 OOM 。我有一个 flutter 应用在 Release 环境中出现 Java Heap OOM 。

    OutOfMemoryError
    
    Failed to allocate a 56 byte allocation with 0 free bytes and 0B until OOM, target footprint 536871360, growth limit 536870912
    

    OOM 时候的内存信息没有上报上来,UncaughtExceptionHandler 那里写的有点问题。这个是个 flutter 应用,几乎所有的内存消耗应该都是 native heap 上,java heap 应该消耗很小。 主要的原生插件是 JustAudio ,Record ,VideoPlayer ,InAppWebview 和文件图片选择。 这是最后一条 onTrimMemory 上报的内存信息,java heap 84mb ,native heap 63mb 。

    {
        jvmFreeMemory: 16860208,
        jvmMaxMemory: 536870912,
        jvmMemory: 84573240,
        largeMemoryClass: 512,
        level: 20,
        memoryClass: 128,
        memoryStats: {
            summary.code: 74212,
            summary.graphics: 138484,
            summary.java-heap: 67844,
            summary.native-heap: 55812,
            summary.private-other: 54184,
            summary.stack: 3124,
            summary.system: 28453,
            summary.total-pss: 422113,
            summary.total-swap: 19104
        },
        nativeHeapAllocatedSize: 63600176,
        nativeHeapFreeSize: 20830672,
        nativeHeapSize: 84430848
    }
    

    这个 OOM 频率虽然很低,但是有反馈,得处理下。 我现在想改下 https://square.github.io/leakcanary/leakcanary-for-releases/。在 release 环境出现 oom 时候 dump 下 heap,下次应用启动时候分析下 heap 。大家有什么好的方法么。

    1 replies    2024-12-25 13:12:55 +08:00
    Helsing
        1
    Helsing  
       Dec 25, 2024 via iPhone
    不要在生产环境用 leakcanary ,那个是测试环境用的,可以看看快手的 KOOM
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   914 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 20:28 · PVG 04:28 · LAX 13:28 · JFK 16:28
    ♥ Do have faith in what you're doing.