Confused about x64 and c#

F

Frank Rizzo

Hello,

I need to port a fairly large app to x64, as it needs access to more
than 2GB. So I ported the app to VS2005 (from vs2003). Now the Project
Properties have a Build Tab, which has a Platform Target dropdown. There
is AnyCPU and x64. I've been reading that AnyCPU means that the app
will run in 64 bit mode on a x64 machine and in x86 mode on the 32bit
machine. Is this really the case?

Also, does running an app compiled with AnyCPU on a 64bit box ensure
that it will be able to access more than 2GB, or do I have to compile
for x64 to make that happen?

Are there any performance differences for running on a 64bit box between
AnyCPU and x64 settings?

Are all the intrinsic data types (int, float, etc...) still the same
size in x64 as they are in x86?

Are there any other questions that I should be asking before porting the
app to x64?

Thanks
 
J

John Vottero

Frank Rizzo said:
Hello,

I need to port a fairly large app to x64, as it needs access to more than
2GB. So I ported the app to VS2005 (from vs2003). Now the Project
Properties have a Build Tab, which has a Platform Target dropdown. There
is AnyCPU and x64. I've been reading that AnyCPU means that the app will
run in 64 bit mode on a x64 machine and in x86 mode on the 32bit machine.
Is this really the case?

Yes, it's really true. And, to be clear, you have to be running the 64bit
version of Windows.

You can also run your app on an Itanium.

Also, does running an app compiled with AnyCPU on a 64bit box ensure that
it will be able to access more than 2GB, or do I have to compile for x64
to make that happen?

If you compile for AnyCPU you will still be able to access more than 2GB on
a 64bit OS.
Are there any performance differences for running on a 64bit box between
AnyCPU and x64 settings?

I'm sure there are but, I don't know what they are or how extensive the
difference might be. I do know that it's NOT a 32bit/64bit difference.
Are all the intrinsic data types (int, float, etc...) still the same size
in x64 as they are in x86?

As far as I know, the only thing that changes size is IntPtr.
Are there any other questions that I should be asking before porting the
app to x64?

If you install your app with an MSI installer, you will need two versions,
one for 64 bit and one for 32bit (and maybe one for Itanium) even though the
installers will all be installing the same executable.
 
W

Willy Denoyette [MVP]

Willy.

| Hello,
|
| I need to port a fairly large app to x64, as it needs access to more
| than 2GB. So I ported the app to VS2005 (from vs2003). Now the Project
| Properties have a Build Tab, which has a Platform Target dropdown. There
| is AnyCPU and x64. I've been reading that AnyCPU means that the app
| will run in 64 bit mode on a x64 machine and in x86 mode on the 32bit
| machine. Is this really the case?
|

AnyCPU = runs as 32bit app on 32 bit windows, as 64bit app on 64 bit windows
(assuming v2 of the framework is available).
x64 = only runs on 64bit windows.

| Also, does running an app compiled with AnyCPU on a 64bit box ensure
| that it will be able to access more than 2GB, or do I have to compile
| for x64 to make that happen?
|

What exactly do you mean with accessing "more than 2GB" of memory.
Remember that even on 64 bit, the max size of an CLR object is limitted to
~2GB. That means that , for instance, a managed array can only contain ~2GB
of real data. Sure, on 64 bit you can have multiple 2GB arrays allocated in
memory, something which isn't possible on a 32bit OS.


| Are there any performance differences for running on a 64bit box between
| AnyCPU and x64 settings?
|
No. They both use the same CLR.


| Are all the intrinsic data types (int, float, etc...) still the same
| size in x64 as they are in x86?
|
Yep.

| Are there any other questions that I should be asking before porting the
| app to x64?
|
Yes, what exactly are you after, especially what exactly do you mean with
2GB memory.


Willy.
 
F

Frank Rizzo

Willy said:
| Also, does running an app compiled with AnyCPU on a 64bit box ensure
| that it will be able to access more than 2GB, or do I have to compile
| for x64 to make that happen?
|
What exactly do you mean with accessing "more than 2GB" of memory.
Remember that even on 64 bit, the max size of an CLR object is limitted to
~2GB. That means that , for instance, a managed array can only contain ~2GB
of real data. Sure, on 64 bit you can have multiple 2GB arrays allocated in
memory, something which isn't possible on a 32bit OS.
| Are there any other questions that I should be asking before porting the
| app to x64?
|
Yes, what exactly are you after, especially what exactly do you mean with
2GB memory.

No, I do not have an array with 2GB of data. Instead, I have a lot of
object trees (running in different threads) with a bunch of data and the
totality may exceeds 2GB (depending on parameters). Today, I get around
the 2GB limit by running several instances of the application. This is
a pain in the a.. as far as setting up and managing the application.
With 64-bit, I could just have one instance of the application installed
and be done with the maintenance problems.

Anyway, the your and John's answers cleared up the picture for me. It
sounds like the port is going to be a breeze and the result will yield
some definite benefits.

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top