namespace NATS.Server.Internal.SysMem;

/// <summary>
/// Cross-platform system memory query helpers.
/// Go reference: server/sysmem/mem_*.go Memory
/// </summary>
public static class SystemMemory
{
    /// <summary>
    /// Returns total memory available to the runtime for the current OS.
    /// </summary>
    public static long Memory()
    {
        var total = GC.GetGCMemoryInfo().TotalAvailableMemoryBytes;
        if (total > 0)
            return total;

        // Conservative fallback when runtime does not report a limit.
        return Environment.Is64BitProcess ? long.MaxValue : int.MaxValue;
    }
}
