I have resorted to using the Win32 API calls VirtualAlloc/VirtualFree to allocate and release memory blocks greater than 2GB in size.
I should be able to use the AllocHGlobal function from the System.Runtime.InteropServices.Marshal class to do the same.
However, the following code gives an arithmetic overflow exception (note the explicit cast to long which should instance a 64 bit pointer).
Dim p As IntPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(New IntPtr(CLng(3221225472)))
System.Runtime.InteropServices.Marshal.FreeHGlobal(p)
So my question is, Can I use AllocHGlobal to allocate more than 2GB of memory? If so, how?