public static int Main(string[] args) {
- uint size = 0;
+ uint sizeInMB = 0;
try {
- size = UInt32.Parse(args[0]);
+ sizeInMB = UInt32.Parse(args[0]);
} catch (Exception e) {
if ( (e is IndexOutOfRangeException) || (e is FormatException) || (e is OverflowException) ) {
- Console.WriteLine("args: uint - number of GB to allocate");
+ Console.WriteLine("args: uint - number of MB to allocate");
return 0;
}
throw;
}
+ int availableMem = MemCheck.GetPhysicalMem();
+ if (availableMem != -1 && availableMem < sizeInMB){
+ sizeInMB = (uint)(availableMem > 300 ? 300 : (availableMem / 2));
+ Console.WriteLine("Not enough memory. Allocating " + sizeInMB + "MB instead.");
+ }
+
CollectTest test = new CollectTest();
- test.size = size;
+ test.size = sizeInMB;
if (test.RunTests()) {
Console.WriteLine("Test passed");
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
- <CLRTestExecutionArguments>2</CLRTestExecutionArguments>
+ <CLRTestExecutionArguments>2048</CLRTestExecutionArguments>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="LargeObject.csproj" />
+ <ProjectReference Include="MemCheck.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
</PropertyGroup>
-</Project>
\ No newline at end of file
+</Project>
public static int Main(string[] args) {
- uint size = 0;
+ uint sizeInMB = 0;
try {
- size = UInt32.Parse(args[0]);
+ sizeInMB = UInt32.Parse(args[0]);
} catch (Exception e) {
if ( (e is IndexOutOfRangeException) || (e is FormatException) || (e is OverflowException) ) {
- Console.WriteLine("args: uint - number of GB to allocate");
+ Console.WriteLine("args: uint - number of MB to allocate");
return 0;
}
throw;
}
+ int availableMem = MemCheck.GetPhysicalMem();
+ if (availableMem != -1 && availableMem < sizeInMB){
+ sizeInMB = (uint)(availableMem > 300 ? 300 : (availableMem / 2));
+ Console.WriteLine("Not enough memory. Allocating " + sizeInMB + "MB instead.");
+ }
+
GetGenerationTest test = new GetGenerationTest();
- test.size = size;
+ test.size = sizeInMB;
if (test.RunTests()) {
Console.WriteLine("Test passed");
return 100;
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
- <CLRTestExecutionArguments>2</CLRTestExecutionArguments>
+ <CLRTestExecutionArguments>2048</CLRTestExecutionArguments>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="LargeObject.csproj" />
+ <ProjectReference Include="MemCheck.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
</PropertyGroup>
-</Project>
\ No newline at end of file
+</Project>
try {
LargeObject lo = new LargeObject(size);
long mem = GC.GetTotalMemory(false);
- long delta = (long)(size*LargeObject.GB)/(long)10;
+ long delta = (long)(size*LargeObject.MB)/(long)10;
- if ( (mem - size*LargeObject.GB)> delta) {
- Console.WriteLine("{0} {1} {2}", mem, size*LargeObject.GB, delta);
+ if ( (mem - size*LargeObject.MB)> delta) {
+ Console.WriteLine("{0} {1} {2}", mem, size*LargeObject.MB, delta);
return false;
}
public static int Main(string[] args) {
- uint size = 0;
+ uint sizeInMB = 0;
try {
- size = UInt32.Parse(args[0]);
+ sizeInMB = UInt32.Parse(args[0]);
} catch (Exception e) {
if ( (e is IndexOutOfRangeException) || (e is FormatException) || (e is OverflowException) ) {
- Console.WriteLine("args: uint - number of GB to allocate");
+ Console.WriteLine("args: uint - number of MB to allocate");
return 0;
}
throw;
}
+ int availableMem = MemCheck.GetPhysicalMem();
+ if (availableMem != -1 && availableMem < sizeInMB){
+ sizeInMB = (uint)(availableMem > 300 ? 300 : (availableMem / 2));
+ Console.WriteLine("Not enough memory. Allocating " + sizeInMB + "MB instead.");
+ }
- GetTotalMemoryTest test = new GetTotalMemoryTest(size);
+ GetTotalMemoryTest test = new GetTotalMemoryTest(sizeInMB);
if (test.RunTests()) {
Console.WriteLine("Test passed");
return 100;
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
- <CLRTestExecutionArguments>2</CLRTestExecutionArguments>
+ <CLRTestExecutionArguments>2048</CLRTestExecutionArguments>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="LargeObject.csproj" />
+ <ProjectReference Include="MemCheck.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
</PropertyGroup>
-</Project>
\ No newline at end of file
+</Project>
public static int Main(string[] args) {
- uint size = 0;
+ uint sizeInMB = 0;
try {
- size = UInt32.Parse(args[0]);
+ sizeInMB = UInt32.Parse(args[0]);
} catch (Exception e) {
if ( (e is IndexOutOfRangeException) || (e is FormatException) || (e is OverflowException) ) {
- Console.WriteLine("args: uint - number of GB to allocate");
+ Console.WriteLine("args: uint - number of MB to allocate");
return 0;
}
throw;
}
+ int availableMem = MemCheck.GetPhysicalMem();
+ if (availableMem != -1 && availableMem < sizeInMB){
+ sizeInMB = (uint)(availableMem > 300 ? 300 : (availableMem / 2));
+ Console.WriteLine("Not enough memory. Allocating " + sizeInMB + "MB instead.");
+ }
- KeepAliveTest test = new KeepAliveTest(size);
+ KeepAliveTest test = new KeepAliveTest(sizeInMB);
if (test.RunTests()) {
Console.WriteLine("Test passed");
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
- <CLRTestExecutionArguments>2</CLRTestExecutionArguments>
+ <CLRTestExecutionArguments>2048</CLRTestExecutionArguments>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="LargeObject.csproj" />
+ <ProjectReference Include="MemCheck.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
</PropertyGroup>
-</Project>
\ No newline at end of file
+</Project>
public sealed class LargeObject {
private byte[][] data;
- private uint sizeInGB;
+ private uint sizeInMB;
private LargeObject next;
public static int FinalizedCount = 0;
- public const long GB = 1024*1024*1024;
+ public const long MB = 1024*1024;
- public LargeObject(uint sizeInGB):this(sizeInGB, false)
+ public LargeObject(uint sizeInMB):this(sizeInMB, false)
{
}
- public LargeObject(uint sizeInGB, bool finalize) {
- this.sizeInGB = sizeInGB;
+ public LargeObject(uint sizeInMB, bool finalize) {
+ this.sizeInMB = sizeInMB;
if (!finalize) {
GC.SuppressFinalize(this);
}
- data = new byte[sizeInGB][];
- for (int i=0; i<sizeInGB; i++) {
- data[i] = new byte[GB];
+ data = new byte[sizeInMB][];
+ for (int i=0; i<sizeInMB; i++) {
+ data[i] = new byte[MB];
}
}
public long Size {
get {
- return sizeInGB*GB;
+ return sizeInMB*MB;
}
}
--- /dev/null
+using System;
+using System.IO;
+using System.Text.RegularExpressions;
+
+public sealed class MemCheck {
+
+ public static int GetPhysicalMem() {
+ if(File.Exists("/proc/meminfo")){
+ string[] lines = System.IO.File.ReadAllLines("/proc/meminfo");
+ foreach(string line in lines){
+ if(line.StartsWith("MemAvailable")){
+ int availableMem = Int32.Parse(Regex.Match(line, @"\d+").Value);
+ return availableMem / 1024;
+ }
+ }
+ }
+ return -1;
+ }
+
+}
+
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <!-- Add Compile Object Here -->
+ <Compile Include="MemCheck.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="$(GCPackagesConfigFileDirectory)extra\project.json" />
+ </ItemGroup>
+ <PropertyGroup>
+ <ProjectJson>$(GCPackagesConfigFileDirectory)extra\project.json</ProjectJson>
+ <ProjectLockJson>$(GCPackagesConfigFileDirectory)extra\project.lock.json</ProjectLockJson>
+ </PropertyGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+ </PropertyGroup>
+</Project>
public static int Main(string[] args) {
- uint size = 0;
+ uint sizeInMB = 0;
try {
- size = UInt32.Parse(args[0]);
+ sizeInMB = UInt32.Parse(args[0]);
} catch (Exception e) {
if ( (e is IndexOutOfRangeException) || (e is FormatException) || (e is OverflowException) ) {
- Console.WriteLine("args: uint - number of GB to allocate");
+ Console.WriteLine("args: uint - number of MB to allocate");
return 0;
}
throw;
}
+ int availableMem = MemCheck.GetPhysicalMem();
+ if (availableMem != -1 && availableMem < sizeInMB){
+ sizeInMB = (uint)(availableMem > 300 ? 300 : (availableMem / 2));
+ Console.WriteLine("Not enough memory. Allocating " + sizeInMB + "MB instead.");
+ }
- ReRegisterForFinalizeTest test = new ReRegisterForFinalizeTest(size);
+ ReRegisterForFinalizeTest test = new ReRegisterForFinalizeTest(sizeInMB);
if (test.RunTests()) {
Console.WriteLine("Test passed");
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
- <CLRTestExecutionArguments>2</CLRTestExecutionArguments>
+ <CLRTestExecutionArguments>2048</CLRTestExecutionArguments>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="LargeObject.csproj" />
+ <ProjectReference Include="MemCheck.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
</PropertyGroup>
-</Project>
\ No newline at end of file
+</Project>
public static int Main(string[] args) {
- uint size = 0;
+ uint sizeInMB = 0;
try {
- size = UInt32.Parse(args[0]);
+ sizeInMB = UInt32.Parse(args[0]);
} catch (Exception e) {
if ( (e is IndexOutOfRangeException) || (e is FormatException) || (e is OverflowException) ) {
- Console.WriteLine("args: uint - number of GB to allocate");
+ Console.WriteLine("args: uint - number of MB to allocate");
return 0;
}
throw;
}
+ int availableMem = MemCheck.GetPhysicalMem();
+ if (availableMem != -1 && availableMem < sizeInMB){
+ sizeInMB = (uint)(availableMem > 300 ? 300 : (availableMem / 2));
+ Console.WriteLine("Not enough memory. Allocating " + sizeInMB + "MB instead.");
+ }
- SuppressFinalizeTest test = new SuppressFinalizeTest(size);
+ SuppressFinalizeTest test = new SuppressFinalizeTest(sizeInMB);
if (test.RunTests()) {
Console.WriteLine("Test passed");
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
- <CLRTestExecutionArguments>2</CLRTestExecutionArguments>
+ <CLRTestExecutionArguments>2048</CLRTestExecutionArguments>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="LargeObject.csproj" />
+ <ProjectReference Include="MemCheck.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
</PropertyGroup>
-</Project>
\ No newline at end of file
+</Project>
private byte[][] data;
- public const long GB = 1024*1024*1024;
+ public const long MB = 1024*1024;
- public LargeObject2(uint sizeInGB)
+ public LargeObject2(uint sizeInMB)
{
- data = new byte[sizeInGB][];
- for (int i=0; i<sizeInGB; i++) {
- data[i] = new byte[GB];
+ data = new byte[sizeInMB][];
+ for (int i=0; i<sizeInMB; i++) {
+ data[i] = new byte[MB];
}
}
public sealed class FinalizerObject {
uint size = 0;
- public FinalizerObject(uint sizeInGB)
+ public FinalizerObject(uint sizeInMB)
{
- size = sizeInGB;
+ size = sizeInMB;
}
~FinalizerObject() {
return;
} catch (Exception e) {
Console.WriteLine("Unexpected Exception");
- Console.WriteLine(e);
+ Console.WriteLine(e.ToString());
return;
}
return false;
} catch (Exception e) {
Console.WriteLine("Unexpected Exception");
- Console.WriteLine(e);
+ Console.WriteLine(e.ToString());
return false;
}
return false;
} catch (Exception e) {
Console.WriteLine("Unexpected Exception");
- Console.WriteLine(e);
+ Console.WriteLine(e.ToString());
return false;
}
GC.WaitForPendingFinalizers();
GC.Collect();
- if (ObjectSize == size*LargeObject.GB) {
+ if (ObjectSize == size*LargeObject.MB) {
Console.WriteLine("allocateInFinalizerTest passed");
return true;
}
- Console.WriteLine("{0} {1}", ObjectSize, size*LargeObject.GB);
+ Console.WriteLine("{0} {1}", ObjectSize, size*LargeObject.MB);
Console.WriteLine("allocateInFinalizerTest failed");
return false;
public static int Main(string[] args) {
- uint size = 0;
+ uint sizeInMB = 0;
try {
- size = UInt32.Parse(args[0]);
+ sizeInMB = UInt32.Parse(args[0]);
} catch (Exception e) {
if ( (e is IndexOutOfRangeException) || (e is FormatException) || (e is OverflowException) ) {
- Console.WriteLine("args: uint - number of GB to allocate");
+ Console.WriteLine("args: uint - number of MB to allocate");
return 0;
}
throw;
}
- FinalizerTest test = new FinalizerTest(size);
+ int availableMem = MemCheck.GetPhysicalMem();
+ if (availableMem != -1 && availableMem < sizeInMB){
+ sizeInMB = (uint)(availableMem > 300 ? 300 : (availableMem / 2));
+ Console.WriteLine("Not enough memory. Allocating " + sizeInMB + "MB instead.");
+ }
+ FinalizerTest test = new FinalizerTest(sizeInMB);
if (test.RunTests()) {
Console.WriteLine("Test passed");
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
- <CLRTestExecutionArguments>2</CLRTestExecutionArguments>
+ <CLRTestExecutionArguments>2048</CLRTestExecutionArguments>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="LargeObject.csproj" />
+ <ProjectReference Include="MemCheck.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
</PropertyGroup>
-</Project>
\ No newline at end of file
+</Project>
// See the LICENSE file in the project root for more information.
using System;
+using System.IO;
public sealed class LargeException : Exception
{
}
}
-
public sealed class LargeExceptionTest {
-
private uint size = 0;
public LargeExceptionTest(uint size) {
this.size = size;
return true;
} catch (Exception e) {
Console.WriteLine("Unexpected Exception");
- Console.WriteLine(e);
+ Console.WriteLine(e.ToString());
return false;
}
-
}
public static int Main(string[] args) {
- uint size = 0;
+ uint sizeInMB = 0;
try {
- size = UInt32.Parse(args[0]);
+ sizeInMB = UInt32.Parse(args[0]);
} catch (Exception e) {
if ( (e is IndexOutOfRangeException) || (e is FormatException) || (e is OverflowException) ) {
- Console.WriteLine("args: uint - number of GB to allocate");
+ Console.WriteLine("args: uint - number of MB to allocate");
return 0;
}
throw;
}
- LargeExceptionTest test = new LargeExceptionTest(size);
+ int availableMem = MemCheck.GetPhysicalMem();
+ if (availableMem != -1 && availableMem < sizeInMB){
+ sizeInMB = (uint)(availableMem > 300 ? 300 : (availableMem / 2));
+ Console.WriteLine("Not enough memory. Allocating " + sizeInMB + "MB instead.");
+ }
+ LargeExceptionTest test = new LargeExceptionTest(sizeInMB);
if (test.RunTests()) {
Console.WriteLine("Test passed");
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
- <CLRTestExecutionArguments>2</CLRTestExecutionArguments>
+ <CLRTestExecutionArguments>2048</CLRTestExecutionArguments>
</PropertyGroup>
<!-- Default configurations to help VS understand the configurations -->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="LargeObject.csproj" />
+ <ProjectReference Include="MemCheck.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
<PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
</PropertyGroup>
-</Project>
\ No newline at end of file
+</Project>
public sealed class LargeObject {
private byte[][] data;
- private uint sizeInGB;
+ private uint sizeInMB;
private LargeObject next;
public static int FinalizedCount = 0;
- public const long GB = 1024*1024*1024;
+ public const long MB = 1024*1024;
- public LargeObject(uint sizeInGB):this(sizeInGB, false)
+ public LargeObject(uint sizeInMB):this(sizeInMB, false)
{
}
- public LargeObject(uint sizeInGB, bool finalize) {
- this.sizeInGB = sizeInGB;
+ public LargeObject(uint sizeInMB, bool finalize) {
+ this.sizeInMB = sizeInMB;
if (!finalize) {
GC.SuppressFinalize(this);
}
- data = new byte[sizeInGB][];
- for (int i=0; i<sizeInGB; i++) {
- data[i] = new byte[GB];
+ data = new byte[sizeInMB][];
+ for (int i=0; i<sizeInMB; i++) {
+ data[i] = new byte[MB];
}
}
public long Size {
get {
- return sizeInGB*GB;
+ return sizeInMB*MB;
}
}
--- /dev/null
+using System;
+using System.IO;
+using System.Text.RegularExpressions;
+
+public sealed class MemCheck {
+
+ public static int GetPhysicalMem() {
+ if(File.Exists("/proc/meminfo")){
+ string[] lines = System.IO.File.ReadAllLines("/proc/meminfo");
+ foreach(string line in lines){
+ if(line.StartsWith("MemAvailable")){
+ int availableMem = Int32.Parse(Regex.Match(line, @"\d+").Value);
+ return availableMem / 1024;
+ }
+ }
+ }
+ return -1;
+ }
+
+}
+
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ <CLRTestKind>BuildOnly</CLRTestKind>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <!-- Add Compile Object Here -->
+ <Compile Include="MemCheck.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ <None Include="$(GCPackagesConfigFileDirectory)extra\project.json" />
+ </ItemGroup>
+ <PropertyGroup>
+ <ProjectJson>$(GCPackagesConfigFileDirectory)extra\project.json</ProjectJson>
+ <ProjectLockJson>$(GCPackagesConfigFileDirectory)extra\project.lock.json</ProjectLockJson>
+ </PropertyGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+ </PropertyGroup>
+</Project>