summaryrefslogtreecommitdiff
path: root/src/System.Private.CoreLib/shared/System/Runtime/MemoryFailPoint.Unix.cs
blob: 2f5305200198b1cea11496f32e31c291d7d973a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace System.Runtime
{
    public sealed partial class MemoryFailPoint
    {
        private static ulong GetTopOfMemory()
        {
            // These values are optimistic assumptions. In reality the value will
            // often be lower.
            return IntPtr.Size == 4 ? uint.MaxValue : ulong.MaxValue;
        }

        private static bool CheckForAvailableMemory(out ulong availPageFile, out ulong totalAddressSpaceFree)
        {
            // TODO: Implement
            availPageFile = 0;
            totalAddressSpaceFree = 0;
            return false;
        }

        // Based on the shouldThrow parameter, this will throw an exception, or 
        // returns whether there is enough space.  In all cases, we update
        // our last known free address space, hopefully avoiding needing to 
        // probe again.
        private static bool CheckForFreeAddressSpace(ulong size, bool shouldThrow)
        {
            // Unreachable until CheckForAvailableMemory is implemented
            return false;
        }

        // Allocate a specified number of bytes, commit them and free them. This should enlarge
        // page file if necessary and possible.
        private static void GrowPageFileIfNecessaryAndPossible(UIntPtr numBytes)
        {
            // Unreachable until CheckForAvailableMemory is implemented
        }
    }
}