Re: Mac Pro memory sizes
Re: Mac Pro memory sizes
- Subject: Re: Mac Pro memory sizes
- From: Kenneth Bruno II <email@hidden>
- Date: Mon, 12 Jan 2009 10:39:48 -0500
On Jan 12, 2009, at 9:50 AM, julius wrote:
So let me then ask: under the 64 bit architecture, will the standard
c types like int, char etc still be available and not give me
problems under garbage collection given I define them as strong?
Currently I'm defining most my variables as type NSInteger and
CGFloat. Is that wrong?
Or should I be implementing my numbers as NSNumber? I thought the
main purpose of NSNumber was as a wrapper to enable us to put
numbers into NSArray etc. Would not using it as the main
representation seriously affect computation speed ? What are other
people doing?
If you have any good links or advice they'd be much appreciated.
From what I understand there won't much change for the smaller
variable types. Going 64 bit just means that the largest variables
available will be larger and that you'll be able to address more
memory at a time. There will be some changes in size and alignment in
some of the variable types but most of these changes will hardly be
noticeable under most circumstances.
NSInteger and NSUInteger are designed so that they will best fit the
environment which the code is compiled for. If you use them then you
generally don't have to worry if you are compiling for 32 bit or 64
bit, these variables are defined with an appropriate size for the
environment. If you need to know what that size is then you can use
the constants NSIntegerMin, NSIntegerMax, and NSUIntegerMax.
NSNumber is an object that holds values for you. You use it when you
can't use a plain variable, such as when you need to store a value in
a container class that only holds objects, such as NSArray. There is
a small performance and memory hit for using NSNumber over a regular
variable but if you use them in small amounts and don't allocate and
deallocate them like mad then you shouldn't have any trouble.
You can learn more about 64 bit computing under Mac OS X here:
<http://developer.apple.com/documentation/Darwin/Conceptual/64bitPorting/intro/chapter_1_section_1.html
>
Here is the section on data type changes:
<http://developer.apple.com/documentation/Darwin/Conceptual/64bitPorting/transition/chapter_3_section_3.html
>
As you can see in that last link the variable types char, short, and
int are staying the same size. Only the variable types long, pointer,
and size_t are changing size. This isn't really a big deal but if you
are writing code to compile for both 32 bit and 64 bit environments
then you might want to do some sanity checks against the max size for
the types that are going to change if you think you might run up
against these limits in the 32 bit environment.
Lastly you can always use the exact-width integer types such as int8_t
which are guaranteed to be at least 8 bits in size. These (and many
more) are defined in the C99 standard:
<http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf>
Honestly though, most of us won't have to worry about these details.
I'd use NSInteger and NSUInteger unless you are dealing with a lot of
very small integers that you need to pack in as little memory as
possible. If you need an object instead of a plain variable then use
NSNumber or NSValue.
- Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden