Pular para o conteúdo
Documentação do Next.js PT-BR
Esta página ainda está em inglês. A tradução ainda não foi feita; o conteúdo abaixo é o original de nextjs.org.

turbopackGcExperimental

The experimental.turbopackGc option controls garbage collection for Turbopack's in-memory and persistent caches. Garbage collection is enabled by default. To disable it, set the option to false:

next.config.ts
import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  experimental: {
    turbopackGc: false,
  },
}

export default nextConfig

Reference

turbopackGc defaults to true and accepts a boolean or an object:

ValueDescription
falseDisables garbage collection.
trueEnables garbage collection with the default timings.
{ minProgressMs?, rootTtlMs? }Enables garbage collection and overrides one or more of the default timings.

When enabled, Turbopack removes unreachable work from memory and its persistent cache. The option applies to both next dev and next build when they use Turbopack.

Good to know:

  • Garbage collection requires the Turbopack FileSystem Cache. The option has no effect when the cache is disabled for the current command.
  • In long-running read-write sessions, Turbopack disables garbage collection when turbopackMemoryEviction is set to false.

Options

The object form accepts the following properties:

PropertyTypeDefaultDescription
minProgressMsNon-negative number100Minimum time a garbage collection pass runs before it honors an interruption.
rootTtlMsNon-negative number259200000 (3 days)Time a garbage collection root can remain unanchored before Turbopack removes it.

The following configuration lets a garbage collection pass run for at least 200 milliseconds before yielding and expires unanchored roots after one day:

next.config.ts
import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  experimental: {
    turbopackGc: {
      minProgressMs: 200,
      rootTtlMs: 24 * 60 * 60 * 1000,
    },
  },
}

export default nextConfig

Version History

VersionChanges
v16.5.0experimental.turbopackGc is enabled by default.
v16.4.0experimental.turbopackGc configuration option added.

Próximos passos