I am trying to allocate unmanaged memory using Marshal.AllocHGlobal
When the size is greater than int.MaxValue (~2GB) I get this error message:
[ERROR] FATAL UNHANDLED EXCEPTION: System.OutOfMemoryException: Out of memory
at (wrapper managed-to-native) System.Runtime.InteropServices.Marshal:AllocHGlobal (intptr)
This error occurs with mono Stable 4.0.4 and Alpha 4.2.1 on Ubuntu Server 14.04 in a virtual machine. Both the mono versions are using the 64-bit architecture. The code is compiled with VS2013 on a windows server 2012R2 machine and I made sure that the code was compiled in 64-bit checking that IntPtr.Size == 8.
On unix, AllocHGlobal uses the same allocator as malloc() does, and it looks like that can't allocate more than a certain amount of memory.
I did this test: on the same machine I used malloc() to allocate 30GB and it worked. I compiled the code using gcc.
Is it possible that AllocHGlobal uses a 32-bit version of malloc()?
Fixed by mono master 60cab7008ba24d189054d52bd39c8c9ee411e9db.