Permalink
Browse files

Limit available memory for 32bit processes to 1.5 GB (that's the max …

…heap size for 32bit)

and renamed AvailablePhysicalMemory to AvailableMemory - this is the memory available to
RavenDB, not the physical memory.
  • Loading branch information...
1 parent f3b8ca3 commit ecef68a508374d22753d6587669f016ba1be7a37 @e-tobi committed Mar 2, 2012
Showing with 6 additions and 5 deletions.
  1. +3 −2 Raven.Database/Config/MemoryStatistics.cs
  2. +3 −3 Raven.Database/Indexing/IndexBatchSizeAutoTuner.cs
@@ -41,7 +41,7 @@ public static int TotalPhysicalMemory
}
}
- public static int AvailablePhysicalMemory
+ public static int AvailableMemory
{
get
{
@@ -76,8 +76,9 @@ public static int AvailablePhysicalMemory
// we are in 32 bits mode, but the _system_ may have more than 4 GB available
// so we have to check the _address space_ as well as the available memory
+ // 32bit processes are limited to 1.5GB of heap memory
var workingSetMb = (int)(Process.GetCurrentProcess().WorkingSet64 / 1024 / 1024);
- return Math.Min(2048 - workingSetMb, availablePhysicalMemoryInMb);
+ return Math.Min(1536 - workingSetMb, availablePhysicalMemoryInMb);
}
catch
{
@@ -70,7 +70,7 @@ private void ConsiderIncreasingBatchSize(int amountOfItemsToIndex, int size)
// not all 10
var sizedPlusIndexingCost = sizeInMegabytes * (1 + (0.25 * Math.Min(context.IndexDefinitionStorage.IndexesCount, context.Configuration.MaxNumberOfParallelIndexTasks)));
- var remainingMemoryAfterBatchSizeIncrease = MemoryStatistics.AvailablePhysicalMemory - sizedPlusIndexingCost;
+ var remainingMemoryAfterBatchSizeIncrease = MemoryStatistics.AvailableMemory - sizedPlusIndexingCost;
if (remainingMemoryAfterBatchSizeIncrease >= context.Configuration.AvailableMemoryForRaisingIndexBatchSizeLimit)
{
@@ -84,7 +84,7 @@ private void ConsiderIncreasingBatchSize(int amountOfItemsToIndex, int size)
private bool ReduceBatchSizeIfCloseToMemoryCeiling()
{
- if (MemoryStatistics.AvailablePhysicalMemory >= context.Configuration.AvailableMemoryForRaisingIndexBatchSizeLimit)
+ if (MemoryStatistics.AvailableMemory >= context.Configuration.AvailableMemoryForRaisingIndexBatchSizeLimit)
{
// there is enough memory available for the next indexing run
return false;
@@ -102,7 +102,7 @@ private bool ReduceBatchSizeIfCloseToMemoryCeiling()
// let us check again after the GC call, do we still need to reduce the batch size?
- if (MemoryStatistics.AvailablePhysicalMemory > context.Configuration.AvailableMemoryForRaisingIndexBatchSizeLimit)
+ if (MemoryStatistics.AvailableMemory > context.Configuration.AvailableMemoryForRaisingIndexBatchSizeLimit)
{
// we don't want to try increasing things, we just hit the ceiling, maybe on the next try
return true;

0 comments on commit ecef68a

Please sign in to comment.