Summary
GC pauses main thread — large object graphs and allocation churn cause jank. Reuse objects in hot paths sparingly; avoid creating huge arrays each frame. performance.memory (Chrome) hints at pressure. Long tasks during idle may be GC — correlate with allocation timeline in Performance panel.
Code example
function processBatch(items) {
const results = new Array(items.length);
for (let i = 0; i < items.length; i++) {
results[i] = transform(items[i]);
}
return results;
}
// Reuse buffers in animation loops instead of allocating each frame
Key points
- GC pauses main thread — large object graphs and allocation churn cause jank.
- Reuse objects in hot paths sparingly; avoid creating huge arrays each frame.
performance.memory(Chrome) hints at pressure.- Long tasks during idle may be GC — correlate with allocation timeline in Performance panel.