Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Memory Leak on Page Navigation on NS7

未关闭
#107 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
20/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
ios, javascript

调研方向

首先使用链接的 NS7 和 NS6 示例项目重现内存泄漏,然后分析 iOS 上重复页面导航的性能,并将其行为与 Android 进行比较。当确定保留内存的来源,并且导航不再导致报告中的内存增长或最终冻结时,该 issue 即完成。

由索引模型根据 Issue 内容生成。

描述

Environment

"@nativescript/core": "7.3.0"

"nativescript-vue": "^2.8.1"

"@nativescript/ios": "7.2.0"

✔ Component nativescript has 7.2.1 version and is up to date.

✔ Component @nativescript/core has 7.3.0 version and is up to date.

✔ Component @nativescript/ios has 7.2.0 version and is up to date.

Describe the bug

NS is not freeing memory on page navigations on iOS. When profiling, on each page navigation, the memory increases and app gets slower until, at some point, the app freezes or the OS terminates the app. This behaviour is restricted to IOS, we have profiled with the Android Runtime (https://github.com/NativeScript/android-runtime) and the garbage collection works as expected.

On a very simple application, two included below, each page navigation increases the memory footprint of the app by 60 - 80 megs until the app reaches 1 - 2 Gigs and stops working. If we have a complex page, with some images, and scroll on a list then the memory increases in small iterations but once we navigate to a new page, the memory jumps by 60 - 80 megs.

We have created several test apps with Vue and Angular and the memory leak occurs irrespective of the JS framework.

Solutions Tried and Reviewed
  1. The same issues has been posted previously - Memory Leak on 7.2.0 with (https://github.com/NativeScript/ns-v8ios-runtime)
    https://github.com/NativeScript/ns-v8ios-runtime/issues/105

    We have also:

    EnableProdMode: Is there something similar to enable prod mode on Vue
    https://github.com/NativeScript/nativescript-angular/issues/1215
    Markingmode: https://nativescript.org/blog/markingmode-none-is-official-boost-android-performance-while-avoiding-memory-issues/

  2. Downgraded Nativescript iOSCore to 6.5.4 (https://github.com/NativeScript/ios-runtime).

    We experience the same issues with the older runtime.

  3. Manually destroyed the component - tried different call backs (Unloaded for example)
    https://github.com/nstudio/nativescript-videoplayer/issues/129

  4. Tried with Angular (its happening even on the creation project templates)

  5. Tried with the templates project with 6.5.4

  6. Set the V8flags in the config for IOS (on the V8 Runtime https://github.com/NativeScript/ns-v8ios-runtime)

  7. Navigating with the clearHistory flag (set to true) and navigateBack method = same result

  8. Tested on simulators and real iPhones. (iOS 12.4.8, iOS 13.1, 13.3.1)

  9. Tested with different Layouts (complex and simple)

  10. Manually calling the GC in the navigate back method reduces the memory by a small percentage (0.1% - 0.3%).

  11. As mentioned, it works on Android, see the profiling from below.
    android memory metrics

Project Examples

We include two sample projects, the first is NS7 and the second NS6, both exhibit the same issues with memory.

NS7: https://github.com/alkimiiapps/memoryleakexample

NS6: https://github.com/alkimiiapps/ns6test

Example Video of the memory reaching 0.5 Gig

Here is a gif of the profiling, where the user navigates back and forth between pages and the memory increases with each navigation.

IMAGE ALT TEXT HERE

主要语言
JavaScript
星标
150
派生
43
平均合并
3 天 10 小时
30 天内合并 PR
22

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

NativeScript/ios 的其他 Issue

查看 NativeScript/ios 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。