Skip to content

Flaky CI: x86 .NET Framework tests fail with memory exhaustion under heavy threading #3608

Closed

Description

@mattleibow

Problem

Two multithreading tests fail consistently on Windows .NET Framework x86 (net472-x86) in CI:

  • SKBitmapThreadingTest.ImageScalingMultipleThreadsTest(100, 1000) — 18 failures across 5 recent builds
  • SKObjectTest.EnsureMultithreadingDoesNotThrow(1000) — 17 failures across 5 recent builds

Both fail with:

System.Exception : Unable to allocate pixels for the bitmap.

Other tests also occasionally fail with the same error or OutOfMemoryException, likely as collateral damage from address space exhaustion:

  • SKImageTest.SubsetEncodesSubset
  • SKCanvasTest.DrawAtlasSupportsTransforms
  • AnimationBuilderTest.CanRenderWithBase64 (OutOfMemoryException)
  • SKFontTest.BreakTextHandlesLongText(131072) (returned 0 — likely allocation failure)

Root Cause

The x86 process has a ~2GB virtual address space limit. These tests create extreme parallel workloads:

  • ImageScalingMultipleThreadsTest(100, 1000): 100 threads × 1000 iterations of decode→scale→encode, plus a background GC.Collect() loop. The ComputeThumbnail helper doesn't dispose bitmaps/images/data, relying on GC which can't keep up.

  • EnsureMultithreadingDoesNotThrow(1000): 1000 concurrent tasks, each decoding a full JPEG to bitmap + allocating byte[height, width].

Impact

These failures cause the Tests stage to fail on every build of main, blocking merges via branch protection.

Recommendations

  1. Add disposal in test loops — ComputeThumbnail leaks bitmap/image/data objects. Add using statements.

  2. Reduce x86 parameters — The (10, 10) variant already tests thread-safety. Skip the stress variant on x86:

    if (IntPtr.Size == 4 && numThreads > 10)
        throw new SkipException("Stress test skipped on x86 (address space limit)");
  3. Isolate stress tests — Run high-memory tests in separate processes to avoid address space poisoning for subsequent tests.

Data

Analyzed 10 recent main builds (156223–156430). These two tests account for 35 of ~46 total test failure instances.

Activity

  1. added
    os/Windows-Classic
    on Mar 29, 2026
  2. added
    status/known-issue
    on Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    os/Windows-Classicstatus/known-issuetype/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions