iOS 上的活动监视器中的实时字节与实内存 [英] Live Bytes vs Real Memory in Activity Monitor on iOS

查看:37
本文介绍了iOS 上的活动监视器中的实时字节与实内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 iOS 应用程序,该应用程序将创建许多小对象和浮点数,并试图了解它消耗了多少内存.

I'm working on an iOS app that will create a lot of small objects and floats, and trying to get an idea for how much memory usage it's consuming.

当我运行Allocations"工具时,它说我有大约 2MB 的Live Bytes",当我在应用程序中移动时,这个数字大致保持不变(当应用程序繁忙时,峰值高达 3MB 左右,但是然后回落到 2MB).

When I run the "Allocations" instrument, it says I have about 2MB of "Live Bytes", and the figure stays roughly constant as I move through the app (spikes up to 3MB or so when the App is busy, but then drops back down to 2MB).

但是当我运行Activity Monitor"工具时,我的应用程序的真实内存"在它完成启动后是 25MB,并且在我的 CALayer 内发生绘图时迅速增长.不到一分钟,它就超过了 100MB.

But when I run the "Activity Monitory" instrument, my app's "Real Memory" is 25MB once it finishes launching, and grows rapidly whenever drawing occurs inside my CALayer. In less than a minute, it goes over 100MB.

为什么Live Bytes"显示为 2MB,而Real Memory"显示为 100MB?

Why would "Live Bytes" show 2MB, but "Real Memory" shows 100MB?

我的 CALayer 正在绘制 的路径,它在几秒钟内将 CPU 固定在 100% 以完成单个绘制操作,并将所有这些点从 NSData 对象加载到CGPoint 值,然后再次释放它们(NSData 对象是所绘制点的压缩版本,存储从一个点到下一个点的增量,所以我将它保存在 RAM 中,但不保存实际的 CGPoints).

My CALayer is drawing tons of paths, it pegs the CPU at 100% for a few seconds just to finish a single draw operation, and it's loading all of these points out of an NSData object into CGPoint values, then deallocing them again (The NSData object is a compressed version of the points being drawn, storing deltas from one point to the next, so I keep it in RAM but don't keep the actual CGPoints).

它还将绘制结果缓存在 UIImage 中,并将这些结果保存在一个先进先出数组中,该数组不会增长到超过 500KB.

It also caches the result of the drawing in a UIImage, and these are kept in a first-in-first-out array that won't grow to more than about 500KB.

推荐答案

原来我的问题是 NSZombieEnabled.

Edit Scheme > Run > Arguments > Environment Variables 中禁用它解决了额外的内存使用.

Disabling that in Edit Scheme > Run > Arguments > Environment Variables solved the extra memory use.

这篇关于iOS 上的活动监视器中的实时字节与实内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆