.net控制台应用程序32对64位

时间:2022-09-01 11:12:19

Does a application in .NET need to be built in 64 bit to take full advantage of a machine with a 64 bit OS on it, or will it take advantage of it just as a 32 bit build. Basically, we have an issue with an out of memory exception and it was suggested to run the console app on a 64 bit box which "may" solve the issue. The question is can we just spin up a 64 box and throw the current app on it or do I need to rebuild the app in a 64 bit way.

.NET中的应用程序是否需要以64位构建才能充分利用具有64位操作系统的计算机,或者它将利用它作为32位构建。基本上,我们遇到内存不足异常的问题,并建议在64位盒子上运行控制台应用程序“可能”解决问题。问题是我们可以启动64个框并将当前应用程序抛出或者我需要以64位方式重建应用程序。

3 个解决方案

#1


If your app is configured to build for the "Any CPU" platform, then it'll run appropriately on either.

如果您的应用程序配置为“任何CPU”平台构建,那么它将适当地运行。

Just make sure it doesn't use any 32/64 bit specific stuff, or you'll run into problems.

只要确保它不使用任何32/64位特定的东西,否则你会遇到问题。

MSDN docs here.

MSDN文档在这里。

For some discussion on drawbacks, see here

有关缺点的一些讨论,请参见此处

#2


If it's built for any platform (the default), it will run in 64 bit on 64bit operating systems.

如果它是为任何平台(默认)构建的,它将在64位操作系统上以64位运行。

That being said, there are still potential issues to watch for. If you interface with native code (via p/invoke, C++/CLI, or COM), then you will need to port that code to 64 bit. If the application is 100% managed, it just works.

话虽如此,仍有潜在的问题值得关注。如果您使用本机代码(通过p / invoke,C ++ / CLI或COM)进行交互,则需要将该代码移植到64位。如果应用程序是100%管理,它只是工作。

#3


"Any CPU" is your friend.

“任何CPU”都是你的朋友。

As an aside:

作为旁白:

We had a particularly large Trie structure that exceeded the 2GB memory space of 32bit Windows. Because most of the structure comprised of object references, we found that the memory requirements of the app nearly doubled when moving to 64bit, requiring around 4gb. This is because the memory to store a reference is 64bits wide instead of 32.

我们有一个特别大的Trie结构,超过了32位Windows的2GB内存空间。由于大多数结构都包含对象引用,我们发现当移动到64位时,应用程序的内存需求几乎翻了一番,需要大约4GB。这是因为存储引用的内存是64位宽而不是32位。

#1


If your app is configured to build for the "Any CPU" platform, then it'll run appropriately on either.

如果您的应用程序配置为“任何CPU”平台构建,那么它将适当地运行。

Just make sure it doesn't use any 32/64 bit specific stuff, or you'll run into problems.

只要确保它不使用任何32/64位特定的东西,否则你会遇到问题。

MSDN docs here.

MSDN文档在这里。

For some discussion on drawbacks, see here

有关缺点的一些讨论,请参见此处

#2


If it's built for any platform (the default), it will run in 64 bit on 64bit operating systems.

如果它是为任何平台(默认)构建的,它将在64位操作系统上以64位运行。

That being said, there are still potential issues to watch for. If you interface with native code (via p/invoke, C++/CLI, or COM), then you will need to port that code to 64 bit. If the application is 100% managed, it just works.

话虽如此,仍有潜在的问题值得关注。如果您使用本机代码(通过p / invoke,C ++ / CLI或COM)进行交互,则需要将该代码移植到64位。如果应用程序是100%管理,它只是工作。

#3


"Any CPU" is your friend.

“任何CPU”都是你的朋友。

As an aside:

作为旁白:

We had a particularly large Trie structure that exceeded the 2GB memory space of 32bit Windows. Because most of the structure comprised of object references, we found that the memory requirements of the app nearly doubled when moving to 64bit, requiring around 4gb. This is because the memory to store a reference is 64bits wide instead of 32.

我们有一个特别大的Trie结构,超过了32位Windows的2GB内存空间。由于大多数结构都包含对象引用,我们发现当移动到64位时,应用程序的内存需求几乎翻了一番,需要大约4GB。这是因为存储引用的内存是64位宽而不是32位。