NSMutableArray对象的总大小 [英] Total Size of NSMutableArray object
问题描述
我有一个 NSMutableArray
,它包含一堆对象,我想知道的是多少内存是数组
使用。看了几个地方后,我知道调用的大小,当我使它得到32位(这是 NSMutableArray
对象的大小自己)。
I've got an NSMutableArray
that holds a bunch of objects, what I'm trying to figure out is how much memory is the array
using. After looking at a couple of places I know about the size of call, and when I make it I get 32 bits (which is the size of the NSMutableArray
object it self).
示例代码:
NSMutableArray *temp = [[NSMutableArray alloc]init];
[temp addObject:objectxyz];
[temp addObject:objectabc];
[temp addObject:object123];
现在我想知道大小:)
推荐答案
要获取数组中的对象数,请使用
To get the number of objects in the array, use
[temp count]
如果你想要数组的总内存使用,你必须循环,加起来每个对象使用多少内存,但我不认为一个通用的对象会给你它的大小。一般来说,你不应该真正担心内存使用。
If you want the total memory usage of the array, you'll have to loop through and add up how much memory each object uses, but I don't think that a generic object will give you its size. In general, you shouldn't really have to worry about memory usage, though.
这篇关于NSMutableArray对象的总大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!