You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2017/04/25 15:51:45 UTC
[2/3] ignite git commit: .NET: Add DefaultMaxSize
.NET: Add DefaultMaxSize
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ead52124
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ead52124
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ead52124
Branch: refs/heads/ignite-5024
Commit: ead52124b6fb2ecd279ab44070147bec5e513bcd
Parents: 30700df
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Tue Apr 25 18:46:46 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Tue Apr 25 18:46:46 2017 +0300
----------------------------------------------------------------------
.../Configuration/MemoryPolicyConfiguration.cs | 7 ++++
.../Apache.Ignite.Core/Impl/NativeMethods.cs | 44 ++++++++++++++++++++
2 files changed, 51 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ead52124/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
index bef57d6..e4b89e1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Cache.Configuration
{
using System.ComponentModel;
using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl;
/// <summary>
/// Defines page memory policy configuration. See <see cref="MemoryConfiguration.MemoryPolicies"/>.
@@ -41,6 +42,11 @@ namespace Apache.Ignite.Core.Cache.Configuration
public const long DefaultInitialSize = 256 * 1024 * 1024;
/// <summary>
+ /// The default maximum size, equals to 80% of total RAM.
+ /// </summary>
+ public static readonly long DefaultMaxSize = (long) ((long) NativeMethods.GetTotalPhysicalMemory() * 0.8);
+
+ /// <summary>
/// Initializes a new instance of the <see cref="MemoryPolicyConfiguration"/> class.
/// </summary>
public MemoryPolicyConfiguration()
@@ -48,6 +54,7 @@ namespace Apache.Ignite.Core.Cache.Configuration
EvictionThreshold = DefaultEvictionThreshold;
EmptyPagesPoolSize = DefaultEmptyPagesPoolSize;
InitialSize = DefaultInitialSize;
+ MaxSize = DefaultMaxSize;
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ead52124/modules/platforms/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
index 3403dee..0004772 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/NativeMethods.cs
@@ -45,5 +45,49 @@ namespace Apache.Ignite.Core.Impl
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Ansi, BestFitMapping = false,
ThrowOnUnmappableChar = true)]
internal static extern IntPtr LoadLibrary(string path);
+
+ /// <summary>
+ /// Gets the total physical memory.
+ /// </summary>
+ internal static ulong GetTotalPhysicalMemory()
+ {
+ var status = new MEMORYSTATUSEX();
+ status.Init();
+
+ GlobalMemoryStatusEx(ref status);
+
+ return status.ullTotalPhys;
+ }
+
+ /// <summary>
+ /// Globals the memory status.
+ /// </summary>
+ [return: MarshalAs(UnmanagedType.Bool)]
+ [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ private static extern bool GlobalMemoryStatusEx([In, Out] ref MEMORYSTATUSEX lpBuffer);
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ // ReSharper disable InconsistentNaming
+ // ReSharper disable MemberCanBePrivate.Local
+ private struct MEMORYSTATUSEX
+ {
+ public uint dwLength;
+ public readonly uint dwMemoryLoad;
+ public readonly ulong ullTotalPhys;
+ public readonly ulong ullAvailPhys;
+ public readonly ulong ullTotalPageFile;
+ public readonly ulong ullAvailPageFile;
+ public readonly ulong ullTotalVirtual;
+ public readonly ulong ullAvailVirtual;
+ public readonly ulong ullAvailExtendedVirtual;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MEMORYSTATUSEX"/> struct.
+ /// </summary>
+ public void Init()
+ {
+ dwLength = (uint) Marshal.SizeOf(typeof(MEMORYSTATUSEX));
+ }
+ }
}
}
\ No newline at end of file