Skip to content

dart test temporary disk usage grows linearly with test file count #2710

Closed

Description

@khoadng

Environment

  • Dart SDK 3.12.2 stable on macOS arm64
  • macOS 26.5.2 (25F84)
  • test 1.31.0

Problem

During dart test, the dart_test.kernel.* temporary directory retains a complete .dill file for every test file. Temporary disk usage grows approximately linearly with the number of test files and is released only when the full command exits.

name: dart_test_kernel_retention_repro
publish_to: none

environment:
  sdk: ^3.12.0

dev_dependencies:
  analyzer: 12.0.0
  test: 1.31.0

Create tool/case_test.dart:

import 'package:analyzer/dart/analysis/utilities.dart';
import 'package:test/test.dart';

void main() {
  test('parses a Dart library', () {
    final result = parseString(
      content: 'class Example { final int value = 1; }',
    );
    expect(result.errors, isEmpty);
  });
}

Copy it into 40 test files:

mkdir -p test
for index in $(seq -w 1 40); do
  cp tool/case_test.dart "test/case_${index}_test.dart"
done

Add test/zz_hold_test.dart to keep the process open long enough to inspect its temporary directory:

import 'dart:async';
import 'package:test/test.dart';

void main() {
  test('hold', () => Future<void>.delayed(const Duration(seconds: 30)));
}

Run:

dart pub get
mkdir -p .tmp
TMPDIR="$PWD/.tmp" dart test

While the hold test is running, inspect the directory from another terminal:

find .tmp -name 'test.dart_*.dill' | wc -l
du -sh .tmp/dart_test.kernel.*

Expected behavior

Temporary disk usage should remain bounded as test files finish.

Actual behavior

The reproduction retains 41 .dill files and uses approximately 950 MB. Each ordinary test file adds approximately 23 MB, although the 40 copied test files contain only about 11 KB of source in total.

In a larger run with 274 test files, the temporary directory exceeded 10 GB and exhausted the available disk space before the command completed.

--verbose output

When the disk filled, the remaining test files failed to load with:

FileSystemException: writeFrom failed, path = '.../dart_test.kernel.<suffix>/output.dill' (OS Error: No space left on device, errno = 28)

Activity

  1. Yusufihsangorgel commented on Aug 12, 2026

    @Yusufihsangorgel
    Contributor

    Every compile copies the frontend server output to a new test.dart_N.dill (test_compiler.dart:159) and nothing deletes them until dispose(). On 1.31.2 I get 11 dills and 242 MiB from 11 test files.

    A suite is finished once cleanupCallbacks runs in platform.dart, but _dillToCache points at the largest dill and is only copied out in dispose(), so just that one has to survive. Do you want a release method on TestCompiler driven from those callbacks, or a different temp layout?

  2. added a commit that references this issue on Sep 29, 2026
    40a5ad9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions