Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
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.