.net 控制台应用程序 32 位与 64 位
.NET 中的应用程序是否需要构建为 64 位才能充分利用装有 64 位操作系统的计算机,还是像 32 位构建一样利用它。 基本上,我们遇到了内存不足异常的问题,建议在 64 位机器上运行控制台应用程序,这“可能”解决该问题。 问题是我们可以启动一个 64 位盒子并将当前应用程序放在上面,还是我需要以 64 位方式重建应用程序。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
“任何CPU”都是你的朋友。
顺便说一句:
我们有一个特别大的 Trie 结构,超过了 32 位 Windows 的 2GB 内存空间。 由于大部分结构由对象引用组成,我们发现应用程序的内存需求在迁移到 64 位时几乎翻倍,需要大约 4GB。 这是因为存储引用的内存是 64 位宽而不是 32 位。
"Any CPU" is your friend.
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.
如果您的应用程序配置为针对“任何 CPU”平台构建,那么它将在任一平台上正常运行。
只需确保它不使用任何 32/64 位特定的东西,否则您会遇到问题。
MSDN 文档此处。
有关缺点的一些讨论,请参阅 此处
If your app is configured to build for the "Any CPU" platform, then it'll run appropriately on either.
Just make sure it doesn't use any 32/64 bit specific stuff, or you'll run into problems.
MSDN docs here.
For some discussion on drawbacks, see here
如果它是为任何平台(默认)构建的,它将在 64 位操作系统上以 64 位运行。
话虽如此,仍然存在需要关注的潜在问题。 如果您与本机代码交互(通过 p/invoke、C++/CLI 或 COM),则需要将该代码移植到 64 位。 如果应用程序得到 100% 的托管,它就可以正常工作。
If it's built for any platform (the default), it will run in 64 bit on 64bit operating systems.
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.