Quantization Issues for a 64-Bit Runtime
In some situations, there may be good reasons to use standard types instead of NSInteger : an “unexpected” memory burst on a 64-bit system.
It is clear that if an integer is 8 instead of 4 bytes, the amount of memory received by the values ​​doubles. Given that not every value is an integer, you generally should not expect your application’s memory to double. However, Mac OS X allocates memory changes based on the amount of requested memory.
Currently, if you request 512 bytes or less, malloc rounded to the next multiple of 16 bytes. However, if you request more than 512 bytes, malloc rounded to the next multiple of 512 (at least 1024 bytes). Suppose you define a class that, among other things, declares five variables of an NSInteger instance, and on a 32-bit system, each instance takes, say, 272 bytes. On a 64-bit system, instances theoretically require 544 bytes. But due to the memory allocation strategy, each will take up 1024 bytes (almost four times as much). If you use a large number of these objects, the memory size of your application may be significantly larger than you might expect. If you replace the NSInteger variables with sint_32 variables, you will only use 512 bytes.
When you choose which scalar to use, so make sure you choose something reasonable. Is there a reason why you need a value greater than what you need in a 32-bit application? Using a 64-bit integer to count a few seconds is hardly needed ...
mmalc Oct 13 '08 at 23:48 2008-10-13 23:48
source share