Skip to content

Commit

Permalink
Linux bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejgordon committed Nov 9, 2023
1 parent f70f4c6 commit bf748c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Elastic.Apm/Metrics/Linux/GlobalMemoryStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal static class GlobalMemoryStatus
#endif

public static (long totalMemory, long availableMemory) GetTotalAndAvailableSystemMemory(IApmLogger logger)
=> GetTotalAndAvailableSystemMemory(logger, ProcMemInfo, false);
=> GetTotalAndAvailableSystemMemory(logger, null, false);

internal static (long totalMemory, long availableMemory) GetTotalAndAvailableSystemMemory(
IApmLogger logger, string pathPrefix, bool ignoreOs)
Expand Down Expand Up @@ -59,7 +59,7 @@ internal static (long totalMemory, long availableMemory) GetTotalAndAvailableSys
{
#if NET6_0_OR_GREATER
using var fs = new FileStream(memInfoPath, Options);
var buffer = ArrayPool<byte>.Shared.Rent((int)fs.Length);
var buffer = ArrayPool<byte>.Shared.Rent(8192); // Should easily be large enough for max meminfo file.

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public void FreeAndTotalMemoryProvider_ShouldReturnValues()

var freeMemory = samples.First().Samples.SingleOrDefault(s => s.KeyValue.Key == FreeAndTotalMemoryProvider.FreeMemory);
freeMemory.Should().NotBeNull();
freeMemory.KeyValue.Value.Should().BeGreaterThan(0);
freeMemory.KeyValue.Value.Should().BePositive();

var totalMemory = samples.First().Samples.SingleOrDefault(s => s.KeyValue.Key == FreeAndTotalMemoryProvider.TotalMemory);
totalMemory.Should().NotBeNull();
totalMemory.KeyValue.Value.Should().BeGreaterThan(0);
totalMemory.KeyValue.Value.Should().BePositive();
}
}

0 comments on commit bf748c5

Please sign in to comment.