64-Bit VB.NET Allocating > 2GB of RAM (.NET bug?)

前端 未结 4 1198
日久生厌
日久生厌 2021-01-13 11:01

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

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-13 11:23

    I think the UnmanagedMemoryStream does what you need. MSDN doc for UnmanagedMemoryStream

    I think it's a bad idea, to allocate a huge chunk of memory in a garbage collected environment, since most garbage collectors are optimized for small & short lived object. So using raw memory is generally a better and more performant solution for very large objects.

提交回复
热议问题