<div dir="ltr"><a href="http://msdn.microsoft.com/en-us/magazine/cc534993.aspx">http://msdn.microsoft.com/en-us/magazine/cc534993.aspx</a><br><div><br></div><div>the LO systems work differently between the two models.</div>
<div><br></div><div>IIRC its +- 80kb on ms</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jun 12, 2014 at 11:38 PM, Neale Ferguson <span dir="ltr"><<a href="mailto:NealeFerguson@verizon.net" target="_blank">NealeFerguson@verizon.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The following program runs fine on .NET -<br>
<br>
using System;<br>
using System.Collections.Generic;<br>
using System.Runtime;<br>
using System.Text;<br>
<br>
namespace LargeObjectTest<br>
{<br>
        class Program<br>
        {<br>
                static void Main(string[] args)<br>
                {<br>
<br>
                        IList<double> myList = new List<double>();<br>
<br>
<br>
                        long index = 1024*1024*1024;<br>
<br>
                        Console.WriteLine("index:" + index);<br>
<br>
                        double[] array = null;<br>
<br>
                        Console.WriteLine("UInt32.MaxValue: "+UInt32.MaxValue);<br>
                        try<br>
                        {<br>
                                array = new double[index];<br>
<br>
                                Console.WriteLine("doubleArray:LongLength " + array.Length * sizeof(double) + " bytes");<br>
                                Console.WriteLine("sizeof(double) " + sizeof(double) + " bytes");<br>
                                Console.WriteLine("index " + index);<br>
                                Console.WriteLine("doubleArray:LongLength " + array.LongLength);<br>
                                Console.WriteLine("doubleArray:Size " + array.LongLength * sizeof(double) * 1.0 + " Bytes");<br>
                        }<br>
                        catch (Exception e)<br>
                        {<br>
                                Console.WriteLine("Exception:" + e);<br>
                                Console.WriteLine("Exception:" + e.Message + " allocating :" + index);<br>
                                Console.WriteLine("Exception:" + e.Message + " allocating :" + index * sizeof(double));<br>
                        }<br>
                }<br>
        }<br>
}<br>
<br>
However, on mono on Linux it results in:<br>
<br>
index:1073741824<br>
UInt32.MaxValue: 4294967295<br>
Exception:System.OutOfMemoryException: Out of memory<br>
  at (wrapper managed-to-native) object:__icall_wrapper_mono_array_new_specific (intptr,int)<br>
  at LargeObjectTest.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0<br>
Exception:Out of memory allocating :1073741824<br>
Exception:Out of memory allocating :8589934592<br>
<br>
If I make the following change to override the SIZE_MAX value from /usr/include/stdint.h:<br>
<br>
--- a/mono/metadata/sgen-los.c<br>
+++ b/mono/metadata/sgen-los.c<br>
@@ -342,8 +342,12 @@ sgen_los_alloc_large_inner (MonoVTable *vtable, size_t size)<br>
         *<br>
         * size <= SIZE_MAX - (mono_pagesize () - 1) - sizeof (LOSObject)<br>
         */<br>
+#undef SIZE_MAX<br>
+#define SIZE_MAX (17179869184U)<br>
        if (size > SIZE_MAX - (mono_pagesize () - 1) - sizeof (LOSObject))<br>
                return NULL;<br>
+#undef SIZE_MAX<br>
+#define SIZE_MAX (4294967295U)<br>
<br>
 #ifdef LOS_DUMMY<br>
        if (!los_segment)<br>
<br>
Then the program works as it does under .NET:<br>
<br>
index:1073741824<br>
UInt32.MaxValue: 4294967295<br>
doubleArray:LongLength 0 bytes<br>
sizeof(double) 8 bytes<br>
index 1073741824<br>
doubleArray:LongLength 1073741824<br>
doubleArray:Size 8589934592 Bytes<br>
<br>
The question is, what is the correct value for the comparison in lieu of SIZE_MAX? I can't determine what the max is on .NET. Another question is what type of compacting happens with large objects like this?<br>
<br>
Neale<br>
<br>
_______________________________________________<br>
Mono-devel-list mailing list<br>
<a href="mailto:Mono-devel-list@lists.ximian.com">Mono-devel-list@lists.ximian.com</a><br>
<a href="http://lists.ximian.com/mailman/listinfo/mono-devel-list" target="_blank">http://lists.ximian.com/mailman/listinfo/mono-devel-list</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Studying for the Turing test</div>
</div>