Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
415 views
in Technique[技术] by (71.8m points)

objective c - Live Bytes vs Real Memory in Activity Monitor on 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.

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).

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.

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

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).

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The Real Memory number includes memory blocks which your app has used and already released, but that the OS hasn't bothered to reclaim or reuse yet (but could if needed). Live memory is "dirty" memory which can't be reclaimed by the OS without killing your app, if your app is running and memory gets too tight.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...