Skip to content

Commit

Permalink
RavenDB-23709 - remove the /admin/debug/memory/smaps endpoint from th…
Browse files Browse the repository at this point in the history
…e debug package
  • Loading branch information
grisha-kotler committed Feb 26, 2025
1 parent 673f2da commit 666247b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Raven.Server/Indexing/LuceneCleaner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ namespace Raven.Server.Indexing;
public class LuceneCleaner : ILowMemoryHandler
{
private readonly AsyncReaderWriterLock _runningQueryLock = new();
private long _lowMemoryOverGeneration;
private long _lowMemoryGeneration = -1;
private static readonly Logger Logger = LoggingSource.Instance.GetLogger<LuceneCleaner>("Memory");

public LuceneCleaner()
Expand All @@ -22,6 +24,12 @@ public LuceneCleaner()

public void LowMemory(LowMemorySeverity lowMemorySeverity)
{
if (_lowMemoryGeneration == _lowMemoryOverGeneration)
{
// we've already run cleanup for this low memory cycle
return;
}

IDisposable writeLock;

using (var cts = new CancellationTokenSource())
Expand Down Expand Up @@ -53,19 +61,22 @@ public void LowMemory(LowMemorySeverity lowMemorySeverity)
writeLock.Dispose();
}

_lowMemoryGeneration = _lowMemoryOverGeneration;

Stopwatch sp = Logger.IsInfoEnabled ? Stopwatch.StartNew() : null;

cacheToDispose.Dispose();

if (sp != null && sp.ElapsedMilliseconds > 100)
{
Logger.Info($"Purged Lucene caches, took: {sp.ElapsedMilliseconds}ms, " +
$"cleaned: {new Size(NativeMemory.TotalLuceneUnmanagedAllocationsForSorting - unmanagedUsedBeforeInBytes, SizeUnit.Bytes)}");
$"cleaned: {new Size(unmanagedUsedBeforeInBytes - NativeMemory.TotalLuceneUnmanagedAllocationsForSorting, SizeUnit.Bytes)}");
}
}

public void LowMemoryOver()
{
_lowMemoryOverGeneration++;
}

public IDisposable EnterRunningQueryReadLock()
Expand Down

0 comments on commit 666247b

Please sign in to comment.