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

Navigate Memory Problem

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

还没有人认领这个 Issue。

评估

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

调研方向

从链接的 atabix/nativescript-memory-leak-example repository 开始,使用 @nativescript/ios 6.5.4 和 7.2.0,将其每秒导航到同一页面的循环复现 30 分钟。在分析内存的同时,阅读所引用的 NativeScript、nativescript-angular 和 ns-v8ios-runtime issues;当泄漏已被隔离,且导航测试不再显示报告中的增长时,即视为完成。

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

描述

I am running into a reproducible memory leak that occurs when navigating to another page.
In my example we navigate with a 1 second timeout to the same page in an endless loop.

Example Repository:
https://github.com/atabix/nativescript-memory-leak-example

➜ nativescript -v
7.2.0

Use Case 1

Run the app with all of the same dependencies with one exception:
@nativescript/ios@6.5.4

Allow the app to run for a period of thirty minutes.

Use Case 2

Run the app with all of the same dependencies with one exception:
@nativescript/ios@7.2.0

Allow the app to run for a period of thirty minutes.

Results

The app starts around ~74MB in both uses cases. In this first couple of minutes the app slowly increases in total memory used, incrementing about 1MB every couple of seconds.

After this initial period the memory seems to stabilize at around 93MB.

The same test has been applied to two very different apps in production with pages that are more complex. This example here resulted in 1MB increments. The production apps resulted in 50MB increments (starting at 146MB and eventually reaching 2GB). In combination with navigating between different kinds of pages this memory problem is compounded, eventually resulting in the app shutting itself down.

This behavior remained consistent when manually calling Utils.GC() and using clearHistory: true on navigation. These two seemed to have no affect on the outcome of the results.

Honorable mention

The issue was first discovered in a project using nativescript-vue. The funny thing is that the amount of memory in each increment used is less than vanilla NativeScript. To remove nativescript-vue as a variable the above uses cases have taken place without it.

References

https://github.com/NativeScript/NativeScript/issues/6890

  • Manual garbage collection doesn't resolve the issue.

https://github.com/NativeScript/nativescript-angular/issues/1215

  • The issue seems to be with Angular. A similar approach was attempted for NativeScript Vue by hooking into the destroy method of Vue components; however, as mentioned above, Vue doesn't seem to be a factor in this problem.

https://github.com/NativeScript/ns-v8ios-runtime/issues/100

  • This is currently an issue in the v7.2.0 iOS runtime. Perhaps it may also be affecting other factors of NativeScript?

I am currently at a loss as to how to proceed. The issue is extremely significant in any pages that display more than a single button and some text. It's only apparent in apps where people navigate between pages a lot for an extended period of time.

主要语言
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 摘要。