a quick question need answered:
which uses more memory?
a nsmutablearray million objects or million nsmutablearrays 1 object?
will there difference?
a million nsmutablearrays 1 object consume more memory.
suppose basic nsmutablearray implementation has pointer , size elements:
- the pointer 4 8 bytes
- the size 4 8 bytes
- then each instance require 2 allocations (one object, 1 array), means addresses tracked someplace.
- add pointer
isa, 4 8 bytes
now not how nsmutablearray implemented, gives idea of memory cost each instance in general purpose implementation.
so rather take sum of parts and:
- add 1000000 *
sizeof(int*) - or multiply 1000000?
that should give idea 1m arrays consume more memory. of course, can test using instruments if need real numbers.
Comments
Post a Comment