dotnet/BenchmarkDotNet · error · NotSupportedException

LargeAddressAware is a Windows-specific concept.

Error message

LargeAddressAware is a Windows-specific concept.

What it means

Thrown when a user sets LargeAddressAware = true on a non-Windows operating system. LargeAddressAware is a Windows PE header flag that lets 32-bit processes access 4 GB of virtual address space instead of 2 GB. The setter explicitly checks OsDetector.IsWindows() and throws NotSupportedException to prevent setting a meaningless flag on Linux/macOS where the concept does not exist.

Source

Thrown at src/BenchmarkDotNet/Jobs/EnvironmentMode.cs:118

        public Guid? PowerPlanMode
        {
            get => PowerPlanModeCharacteristic[this];
            set => PowerPlanModeCharacteristic[this] = value;
        }

        /// <summary>
        /// Specifies that benchmark can handle addresses larger than 2 gigabytes.
        /// <value>false: Benchmark uses the default (64-bit: enabled; 32-bit:disabled). This is the default.</value>
        /// <value>true: Explicitly specify that benchmark can handle addresses larger than 2 gigabytes.</value>
        /// </summary>
        public bool LargeAddressAware
        {
            get => LargeAddressAwareCharacteristic[this];
            set
            {
                if (value && !OsDetector.IsWindows())
                {
                    throw new NotSupportedException("LargeAddressAware is a Windows-specific concept.");
                }

                LargeAddressAwareCharacteristic[this] = value;
            }
        }

        /// <summary>
        /// Adds the specified <paramref name="variable"/> to <see cref="EnvironmentVariables"/>.
        /// If <see cref="EnvironmentVariables"/> already contains a variable with the same key,
        /// it will be overriden.
        /// </summary>
        /// <param name="variable">The new environment variable which should be added to <see cref="EnvironmentVariables"/></param>
        public void SetEnvironmentVariable(EnvironmentVariable variable)
        {
            var newVariables = new List<EnvironmentVariable>();
            newVariables.AddRange(EnvironmentVariables);
            newVariables.RemoveAll(v => v.Key.Equals(variable.Key, StringComparison.Ordinal));
            newVariables.Add(variable);

View on GitHub (pinned to b515068b61)

Solutions

  1. Guard the call with an OS check: if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) job.WithLargeAddressAware(true)
  2. Only set LargeAddressAware in a platform-specific configuration block rather than a shared config.
  3. Remove the LargeAddressAware setting if targeting only 64-bit processes (64-bit already has full large address support by default).

Example fix

// before
var job = Job.Default.WithLargeAddressAware(true);

// after
var job = Job.Default;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
    job = job.WithLargeAddressAware(true);
Defensive patterns

Strategy: validation

Validate before calling

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
    job = job.WithLargeAddressAware(true);
}

Type guard

static bool CanSetLargeAddressAware() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

Prevention

When it happens

Trigger: Calling job.Configure(EnvironmentMode).LargeAddressAware = true or using the fluent API .WithLargeAddressAware(true) while running BenchmarkDotNet on Linux or macOS. The condition `value && !OsDetector.IsWindows()` evaluates true.

Common situations: Developers writing benchmarks on Windows that set LargeAddressAware for 32-bit memory-intensive benchmarks, then running the same benchmark suite in a Linux CI pipeline or Docker container. Also occurs when configuration is shared cross-platform via a common config class.

Related errors


AI-assisted analysis of dotnet/BenchmarkDotNet@b515068b61 (2026-08-13). Data as JSON: /api/errors/56fbcad2152d4b7c. Report an issue: GitHub.