ios react

by Jignesh Kakadiya

通过Jignesh Kakadiya

查找内存泄漏React本机应用程序(iOS) (Finding memory leaks react-native app (iOS))

Problem:Our react-native app was working well on all devices and except iPhone 6 it was resulting in a crash. After high level profiling we found out that its a memory issue. While using some heavy features in the app memory was shooting up to 600+ MB. And since iPhone 6 has 1GB of ram, iPhone automatically kills the app.

问题:我们的本机应用程序在所有设备上均运行良好,并且除iPhone 6外,它均导致崩溃。 经过高级分析后,我们发现这是一个内存问题。 在应用程序中使用一些繁重的功能时,内存最大可存储600 MB以上的内存。 而且由于iPhone 6具有1GB的内存,iPhone会自动终止该应用程序。

Solution:This is what I did to reduce app total memory usage from 600MB to 60MB.

解决方案:这是我将应用程序的总内存使用量从600MB减少到60MB的工作。

  1. While profiling for memory leaks we need to make sure app is built with the release Scheme. Since dev build includes logging/warning, hot reloading features we don’t need them when checking for leaks. This is how you can change the release build with xcode.

    在分析内存泄漏时,我们需要确保应用程序是使用发布方案构建的。 由于开发版本包含日志记录/警告和热重载功能,因此在检查泄漏时不需要它们。 这就是您可以使用xcode更改发行版的方法 。

  2. Start tracking for leaks

    开始跟踪泄漏

    Go to XCode → Product → Profile (⌘ + i)

    转到XCode→产品→配置文件(⌘+ i)

    It will popup profiling templates. Please select whichever is required.

    它将弹出分析模板。 请选择所需的内容。

    Select

    选择

    Leaksand click on choose.

    Leaks并单击choose

3. This should open the leaks profiler on your screen. Then you can click on the `red dot` on top left corner which will restart the app in simulator and you can start playing with the app.

3.这将在屏幕上打开泄漏分析器。 然后,您可以单击左上角的“红点”,这将在模拟器中重新启动该应用程序,然后您就可以开始使用该应用程序了。

4. This is how it looks after performing some swipes in the screen and carousel operations. I realised when I jump into the carousel screen and select an image from carousel of 12 images, memory shoots up for every single image. Result below shows us the memory taken by “in memory” image objects.

4.这是在屏幕上进行一些滑动和轮播操作后的外观。 我意识到,当我跳入轮播屏幕并从12个图像的轮播中选择一个图像时,每张图像都会增加内存。 以下结果向我们展示了“内存中”图像对象占用的内存。

5. Finding the cause.We were using the react-native-fast-image package for caching the images on that screen and since react-native doesn’t have a “better” way to cache fetched images we ended up using react-native-fast-image. So I decided to remove this wonderful package from my app, and result was shocking. This is what the result looks like after removing it.

5. 查找原因。 我们使用react-native-fast-image包在该屏幕上缓存图像,由于react-native并没有“更好”的方式来缓存获取的图像,因此我们最终使用了react-native-fast-image 。 因此,我决定从我的应用程序中删除此精美的程序包,结果令人震惊。 这是删除后的结果。

PS: Just so you know we ended up using react-native-cached-image, which doesn’t store image in memory.

PS:如此您就知道我们最终使用了react-native-cached-image ,它不将图像存储在内存中。

If you are building something with react-native and need help. Please let me know.

如果您要使用本机构建东西,并且需要帮助。 请告诉我。

翻译自: https://www.freecodecamp.org/news/finding-memory-leaks-react-native-app-ios-46e6eeb50c8c/

ios react

ios react_查找内存泄漏React本机应用程序(iOS)相关推荐

  1. 使用Xcode的memory graph查找内存泄漏

    由donnywals于2019年12月9日发布 代码无法充分发挥功能的原因很多. 在一篇文章中,我向您展示了如何使用Time Profiler来测量代码中每种方法所花费的时间,以及如何分析结果. 尽管 ...

  2. java 内存泄漏 工具_Java剖析工具JProfiler入门使用教程:查找内存泄漏的方法

    JProfiler的内存视图会话提供了内存使用情况的动态更新视图以及分配点的信息视图.所有的视图都有几个聚集层并且能够显示现有存在的对象和作为垃圾回收的对象.本文主要介绍如何意识到内存泄漏以及查找内存 ...

  3. 使用UMDH查找内存泄漏

    预览: 使用UMDH分析查找内存泄漏技术 上半年对内存泄漏查找作了一个总结,主要是使用crt的debug版本查找内存泄漏,但是存在的缺陷是只能定位到用户代码中自己分配的内存,对于使用其他库中分配的内存 ...

  4. Umdhtools.exe: 如何使用 umdh.exe 来查找内存泄漏

    使用 UMDH 之前 如果您认为您遇到内存泄漏, 应注意, 内存泄漏可能不它们似乎什么. 您可能发现内存泄漏是不满足内存泄漏, 但是性能增强. 例如, MicrosoftJet 数据库引擎会消耗大量内 ...

  5. 使用VLD查找内存泄漏

    内存泄漏查找----------VLD VLD是VC++ 提供的内存泄漏查找工具 只能用于VC++编译器! 开始 下载地址:https://vld.codeplex.com/releases  ,下载 ...

  6. 利用Android Studio的 Monitor Memory 查找内存泄漏

    App开发总会遇到内存泄漏的情况,在Eclipse时代我们一般使用MAT来配合分析,Android Studio会方便一些,因为它自带了一个Monitor Memory.下面我们来看看怎么使用这个工具 ...

  7. Windows 10 查找内存泄漏程序

    Windows 10 运行一段时间内存占用会爆满,Non-paged pool 占用内存会剧增,好多G. 网上查询资料,此情况通常是驱动之类导致的内存泄漏,尤其可能是网卡驱动.更新主板.网卡驱动之类后 ...

  8. [iOS] AFNetworking 的内存泄漏分析

    本文分析了使用 AFNetworking 组件时遇见的内存泄漏问题的根本原因,并给出解决方案. 当第一次学会使用 Leaks 时,便拿了公司的 APP 项目练手测试了一下.结果测试刚开始,便出现了 L ...

  9. iOS开发之内存泄漏检测工具-Leaks

    引言 我们在实际开发过程中,经常会不小心造成循环引用问题,从而造成内存泄漏问题,那么我们该如何检测我们工程那个位置存在内存泄漏问题呢?这就需要用到Xcode自带的内存泄漏检测工具-Leaks. 内存泄 ...

最新文章

  1. 业务逻辑全写在sql_TiDB 在转转的业务实战
  2. linux mint 17.3 内核,LinuxMint 17.3 Cinnamon抢鲜评测
  3. 多用户使用一台计算机可设置,《计算机应用基础》试卷(A)
  4. Django 基础教程
  5. PHPexcel实列
  6. 阿里云、小米、华为手机竞争对比初评
  7. 企业注册一站式服务平台公司宝App挂牌新三板
  8. HDU1406 完数【水题】
  9. 5.Jenkins 权威指南 --- 安全
  10. android gradle abi mips x86,APP_ABI := armeabi armeabi-v7a mips x86与= armeabi armeabi-v7a区别是?...
  11. HTML基础标签和基本CSS行内样式
  12. modbus tcp主站和从站_实例分享!西门子PLC通过MODBUS控制变频器
  13. MiFlash 刷机有感
  14. python unpack java,Java中的python struct.unpack - java
  15. 20220525商汤算法岗实习面试经历
  16. 禁止查看网页源代码方法
  17. 安装黑群晖找不到局域网电脑_UNRAID 、黑群晖、 穿越派 私有云部署测试
  18. Push Pull:注意力攻击生成可迁移对抗样本
  19. 集成本地图片、云图片存储的思路
  20. Minecraft教育版——两个村庄的故事

热门文章

  1. 事务相关命令 mysql
  2. 文件类常用方法 c# 1614531951
  3. 模式窗体 winform 1201
  4. 项目 我行我素购物管理系统 0913
  5. linux scp限制传输速度
  6. (转)使用异步Python 3.6和Redis编写快速应用程序
  7. HDU1253 胜利大逃亡
  8. 子网与子网掩码的介绍
  9. Dotnet中Socket网络通信
  10. 泛型那点儿事儿 泛型概述 简单样例代码