Skip to content

Instantly share code, notes, and snippets.

@antdimot
Last active June 13, 2019 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antdimot/9bc9c293e7947f38e4ffb7816a46df29 to your computer and use it in GitHub Desktop.
Save antdimot/9bc9c293e7947f38e4ffb7816a46df29 to your computer and use it in GitHub Desktop.
.net memory test
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