Guia de entrevista · Node.js

When does the Garbage Collector run?

do caderno de estudos · atualizado em 2 de outubro de 2026
Para quem vai encarar entrevista de Node.js2 min

Resposta curta e em inglês, para ler, fechar e treinar em voz alta.

A resposta, como você fala na entrevista

V8 schedules garbage collection using allocation pressure and runtime heuristics. Young and old objects are handled differently, and collection can include both background work and pauses on the JavaScript thread. Do not memorize a fixed heap percentage as a runtime contract.

A rising heap between collections is normal. Investigate sustained growth in memory retained after comparable collections under a comparable workload. Record heap, external memory, RSS, and GC pause duration before deciding that there is a leak.

Source: Node.js GC tracing.

Ler é o primeiro passo. No app, essa pergunta vira flashcard com repetição espaçada, e o módulo tem quiz e simulado para testar o que ficou.

Treinar essa pergunta no app