Last active
June 13, 2019 12:37
-
-
Save antdimot/9bc9c293e7947f38e4ffb7816a46df29 to your computer and use it in GitHub Desktop.
.net memory test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace ConsoleApp1 | |
{ | |
// 1 gigabyte (GB) = 1073741824 bytes | |
// 2 gigabyte (GB) = 2147483648 bytes | |
class Program | |
{ | |
static void Main( string[] args ) | |
{ | |
//int size = 130000000; // --> 2080000000 bytes | |
int size = 140000000; // --> 2240000000 bytes | |
//int size = 201326592; // --> 3221225472 bytes | |
//int size = 268435456; // --> 4294967296 bytes | |
ComplexNumber[] myarray = null; | |
try | |
{ | |
myarray = new ComplexNumber[size]; | |
Console.Write( "Programs ends correctly." ); | |
} | |
catch( Exception ex ) | |
{ | |
Console.WriteLine( ex.Message ); | |
} | |
Console.ReadLine(); | |
} | |
} | |
// it uses about 16 bytes | |
public struct ComplexNumber | |
{ | |
public double Re; | |
public double Im; | |
public ComplexNumber( double re, double im ) | |
{ | |
Re = re; | |
Im = im; | |
} | |
} | |
} | |
<?xml version="1.0" encoding="utf-8"?> | |
<configuration> | |
<runtime> | |
<gcAllowVeryLargeObjects enabled="true"></gcAllowVeryLargeObjects> | |
</runtime> | |
</configuration> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment