summaryrefslogtreecommitdiff
path: root/tests/src/GC/Stress/Tests/LargeObjectAlloc2.cs
diff options
context:
space:
mode:
authorKoundinya Veluri <kouvel@microsoft.com>2015-09-30 12:20:52 -0700
committerBryan P. Arant <bryanar@microsoft.com>2015-10-15 03:15:54 +0000
commit4cf34fe7988ad04eaa7f699a5d0faea8a8394f95 (patch)
tree29cc1fd9de029a9b8a1c0e2f7e57e5a3e568667a /tests/src/GC/Stress/Tests/LargeObjectAlloc2.cs
parent06579986abb889d2a509be7e2c6370b4fa363fd6 (diff)
downloadcoreclr-4cf34fe7988ad04eaa7f699a5d0faea8a8394f95.tar.gz
coreclr-4cf34fe7988ad04eaa7f699a5d0faea8a8394f95.tar.bz2
coreclr-4cf34fe7988ad04eaa7f699a5d0faea8a8394f95.zip
Changes to Test Infrastructure
The following changes are being submitted in order to prepare for a large collection of tests to be ported from the internal legacy test tree. - Adds "build kinds" to the test tree. - Adds some documentation for the test tree - Adds a Test Priority feature (see documentation Documentation/project-docs/tests.md for more information. - Dropped the cs_template.csproj types and converted to individual CSProject files.
Diffstat (limited to 'tests/src/GC/Stress/Tests/LargeObjectAlloc2.cs')
-rw-r--r--tests/src/GC/Stress/Tests/LargeObjectAlloc2.cs90
1 files changed, 90 insertions, 0 deletions
diff --git a/tests/src/GC/Stress/Tests/LargeObjectAlloc2.cs b/tests/src/GC/Stress/Tests/LargeObjectAlloc2.cs
new file mode 100644
index 0000000000..c8ff41d43a
--- /dev/null
+++ b/tests/src/GC/Stress/Tests/LargeObjectAlloc2.cs
@@ -0,0 +1,90 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+// Allocate nested objects of ~ 25 MB
+// If memory is low, after every loop, the large objects should be collected
+// and committed from the LargeObjectHeap
+// The Finalizer makes sure that the GC is actually collecting the large objects
+
+
+using System;
+
+namespace LargeObjectTest
+{
+ public class OtherLargeObject
+ {
+ // disabling unused variable warning
+#pragma warning disable 0414
+ private int[] _otherarray;
+#pragma warning restore 0414
+
+ public OtherLargeObject()
+ {
+ _otherarray = new int[5000]; // 20 KB
+ }
+ }
+
+ public class LargeObject
+ {
+ // disabling unused variable warning
+#pragma warning disable 0414
+ private int[] _array;
+#pragma warning restore 0414
+ private OtherLargeObject[] _olargeobj;
+
+ public LargeObject()
+ {
+ _array = new int[1250000]; // 5 MB
+ _olargeobj = new OtherLargeObject[1000]; //20 MB
+ for (int i = 0; i < 1000; i++)
+ {
+ _olargeobj[i] = new OtherLargeObject();
+ }
+ }
+
+ ~LargeObject()
+ {
+ TestLibrary.Logging.WriteLine("In finalizer");
+ Test.ExitCode = 100;
+ }
+ }
+
+ public class Test
+ {
+ public static int ExitCode = -1;
+
+ public static int Main()
+ {
+ int loop = 0;
+ LargeObject largeobj;
+
+ TestLibrary.Logging.WriteLine("Test should pass with ExitCode 100\n");
+
+
+ while (loop <= 200)
+ {
+ loop++;
+ TestLibrary.Logging.Write(String.Format("LOOP: {0}\n", loop));
+ try
+ {
+ largeobj = new LargeObject();
+ TestLibrary.Logging.WriteLine("Allocated LargeObject");
+ }
+ catch (Exception e)
+ {
+ TestLibrary.Logging.WriteLine("Failure to allocate at loop {0}\n", loop);
+ TestLibrary.Logging.WriteLine("Caught Exception: {0}", e);
+ return 1;
+ }
+ largeobj = null;
+ GC.Collect();
+ GC.WaitForPendingFinalizers();
+ TestLibrary.Logging.WriteLine("LargeObject Collected\n");
+ }
+ TestLibrary.Logging.WriteLine("Test Passed");
+ GC.Collect();
+
+ return ExitCode;
+ }
+ }
+}