64 位 VB.NET 分配 >2GB 内存(.NET 错误?) [英] 64-Bit VB.NET Allocating > 2GB of RAM (.NET bug?)

查看:30
本文介绍了64 位 VB.NET 分配 >2GB 内存(.NET 错误?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 64 位的 VB.NET 应用程序,想分配一个大于 2GB 的缓冲区.

在下面的代码中,new"和ReDim"都抛出了一个OverflowException".

当这些函数只接受有符号的 32 位值时,如何分配大于 2GB 的缓冲区?

(这在 C# 中可行吗?)

编辑 - 我运行的是带有 4GB RAM 的 WinXP 64.

<前>Dim 宽度 As Long = 19005Dim 高度 As Long = 32768Dim buffer() As Byte = New Byte((width * height * 4) - 1) {}Dim size As Long = (width * height * 4) - 1ReDim 缓冲区(大小)

解决方案

显然,即使在 64 位操作系统上运行的 64 位 .net 应用程序下,分配的空间也不可能超过 2GB.

我发现这非常令人失望,而且完全不考虑 64 位应用程序和操作系统的用途.我正在处理 巨大 图像,并希望能够同时处理 RAM 中的所有原始字节.现在我必须实现分页算法以将块限制为 2GB.

嘿微软,你如何在即将发布的 .NET 版本中解决这个问题?是的,我说修复.那是因为它坏了.当您做这样的愚蠢事情时,您如何期望 64 位应用程序起飞.(你能说我生气.)谢谢你的聆听.

链接

http://blogs.msdn.com/joshwil/archive/2005/08/10/450202.aspx

I have a 64 bit VB.NET application and want to allocate a buffer > 2GB in size.

In the following code both the "new" and the "ReDim" throw an "OverflowException."

How can I allocate buffers > 2GB when these functions only accept signed 32 bit values?

(Is this possible in C#?)

Edit - I am running WinXP 64 with 4GB of RAM.

Dim width As Long = 19005
Dim height As Long = 32768

Dim buffer() As Byte = New Byte((width * height * 4) - 1) {}

Dim size As Long = (width * height * 4) - 1
ReDim buffer(size)

解决方案

Apparently it is not possible to allocate more than 2GB even under 64 bit .net application running on a 64 bit OS.

I find this to be very disappointing and completely without regard for what 64 bit applications and OSs are made for. I am dealing with gigantic images and would like to be able to work with the raw bytes all in RAM at once. Now I have to implement paging algorithms to limit the chunks to 2GB.

Hey Microsoft, hows abouts you fix this in the coming .NET release? Yes, I said fix. That's because it's broken. How do you expect 64 bit applications to take off when you do stupid things like this. (Can you tell that I am annoyed.) Thanks for listening.

Link

http://blogs.msdn.com/joshwil/archive/2005/08/10/450202.aspx

这篇关于64 位 VB.NET 分配 &gt;2GB 内存(.NET 错误?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆