Any CPU or x64?

Asked

Viewed 857 times

6

I searched for compilation on Any CPU and x64, but found nothing regarding performance and file size. There is difference between these two in this question when the machine is x64?

Website using C# in VS 2017, MVC 3, . NET Framework 4.7

  • 3

    If you try to make the question a little clearer than you want, if it is C#, etc. you can ask a good question.

  • It’s not about the c#, it’s about compiling it, it’s about the difference between the final compilation product on anycpu and x64 when you run it on an x64 machine. end files have different sizes? software performance is the same?

  • 1

    Compile where? Using what? Anycpu has to do with C#. . NET Framework, Core or Native?

  • Vs2017, code written in c# MVC 3 . NET Framework 4.7 Sorry, my bad

1 answer

11


No. NET Framework makes no difference in terms of executable size because the generated code is a CIL and not a native code, what goes is a bytecode that on execution will generate a native code through the Jitter.

What changes when you choose a CPU or leave it to anyone is where the code can run, is to create the right dependencies.

If you have any native dependency it may make a difference.

If you choose x64 you cannot run on an x86 machine and if you choose x86 you will run in x64 compatibility mode.

If you choose Any CPU o Runtime will generate native code according to the architecture it is running.

Assemblies of. NET cannot mix architectures, so if you choose one of them, you can only run along with assemblies of the same architecture.

The native x64 code will be slightly larger because all addressing will occupy 8 bytes instead of 4 bytes which is the size of x86. There are other differences of instructions that can make the native code in memory become larger or smaller.

Generally the x64 runs faster, but not always. But do not need to choose, let Any CPU.

In some cases choosing the x86 can give some advantage, just testing to know.

The CLR choose the best shape when it is in Any CPU, so it is almost always the best choice. In general you only need to choose the architecture if you are going to run together an unmanaged code for one of them specifically.

Article with more details.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.