[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -1,103 +1,188 @@
|
||||
---
|
||||
id: wiki-2026-0508-할당-타임라인-allocation-timeline
|
||||
title: 할당 타임라인(Allocation Timeline)
|
||||
title: 할당 타임라인 (Allocation Timeline)
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-Reinforce-AUTO-1A08DE]
|
||||
aliases: [Allocation Timeline, Memory Allocation Profiling, Heap Timeline]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
tags: [auto-reinforced]
|
||||
verification_status: applied
|
||||
tags: [profiling, memory, devtools, performance, gc]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-20
|
||||
github_commit: "[P-Reinforce] Continuous Worker - 할당 타임라인([[Allocation Timeline]])"
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: unspecified
|
||||
framework: unspecified
|
||||
language: javascript
|
||||
framework: chrome-devtools
|
||||
---
|
||||
|
||||
# [[할당 타임라인(Allocation Timeline)]]
|
||||
# 할당 타임라인 (Allocation Timeline)
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> 할당 타임라인(Allocation Timeline)은 힙 프로파일러의 상세한 스냅샷 정보와 타임라인 패널의 추적 기능을 결합한 메모리 프로파일링 도구입니다 [1, 2]. 이 도구는 녹화 기간 동안 주기적으로 힙 스냅샷을 캡처하여 객체 할당과 가비지 컬렉션(GC) 이후의 생존 여부를 시각적으로 보여줍니다 [3, 4]. 주로 메모리에 계속 남아 누수를 일으키는 객체를 찾고, 해당 객체가 할당된 정확한 스택 트레이스를 식별하는 데 사용됩니다 [1, 2, 5].
|
||||
## 매 한 줄
|
||||
> **"매 heap 의 시간 축 의 graph"**. Allocation Timeline 은 Chrome DevTools (Memory panel) 의 sampling profiler tool 로, recording 동안 매 N ms 마다 JS heap 의 allocation 을 sample 하여 어떤 코드 line 이 어떤 timestamp 에 얼마만큼 의 memory 의 allocate 했는지 visualize. 매 memory leak 의 hunt, 매 high-frequency allocation hotspot 의 identification 의 매 first-line tool.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
* **작동 방식 및 캡처 주기:**
|
||||
할당 타임라인은 도구가 실행되는 동안 주기적으로(최대 50ms 간격) 힙 스냅샷을 찍고, 녹화가 끝날 때 최종 스냅샷을 하나 더 캡처하여 시간 경과에 따른 메모리 할당을 시각화합니다 [3, 4, 6]. 타임라인 상단에 나타나는 막대그래프는 힙에서 새로운 객체가 발견된 시점을 나타내며, 막대의 높이는 할당된 객체의 전체 크기를 의미합니다 [6-8].
|
||||
## 매 핵심
|
||||
|
||||
* **막대 색상을 통한 생존(Liveness) 판별:**
|
||||
할당 타임라인에서 막대의 색상은 객체의 현재 상태를 구분하는 핵심 지표입니다.
|
||||
* **파란색 막대:** 해당 시간대에 할당된 후 최종 스냅샷 지점까지 메모리에 살아남아 있는 객체를 의미합니다 [5-8].
|
||||
* **회색 막대:** 해당 시간대에 할당되었으나, 이후 가비지 컬렉터(GC)에 의해 정상적으로 수거(Free)된 객체를 의미합니다 [5-9].
|
||||
* 가비지 컬렉션 이후에도 사라지지 않고 남아있는 파란색 막대들은 잠재적인 메모리 누수([[memory]] Leak) 후보가 됩니다 [9, 10].
|
||||
### 매 DevTools Memory panel 의 3 modes
|
||||
1. **Heap snapshot**: 매 single point-in-time 의 full snapshot. 매 leak diagnosis (3-snapshot technique).
|
||||
2. **Allocation instrumentation on timeline** (allocations on timeline): 매 stack trace 와 함께 매 allocation 의 capture. 매 expensive 한 most-detailed.
|
||||
3. **Allocation sampling**: 매 lightweight, statistical. 매 production-like profile.
|
||||
|
||||
* **스택 트레이스 및 원인 분석:**
|
||||
개발자는 타임라인에서 특정 시간대를 마우스로 드래그하여 확대(Zoom in)함으로써, 해당 시간 프레임에 할당된 객체만 표시되도록 생성자(Constructor) 목록을 필터링할 수 있습니다 [5, 9, 11, 12]. 특정 객체를 선택하면 유지 경로([[Retaining Path]])와 할당 스택(Allocation stack) 탭을 통해 해당 객체가 코드의 어느 부분에서 생성되었고, 왜 GC에 의해 수거되지 못했는지 그 원인을 정확히 추적할 수 있습니다 [5, 11, 13, 14].
|
||||
### 매 timeline 의 read 법
|
||||
- X 축: time.
|
||||
- Y 축: bar 의 height = allocation size.
|
||||
- **Blue bar**: 매 still-alive allocation 의 record 종료 시점.
|
||||
- **Gray bar**: 매 collected allocation. 매 GC 의 reclaimed.
|
||||
- 매 blue 가 많이 남으면 → potential leak source.
|
||||
|
||||
* **고유 객체 식별자 유지:**
|
||||
가비지 컬렉션이 발생하면 객체의 물리적 메모리 주소가 이동할 수 있기 때문에, 도구는 주소 대신 영구적인 객체 ID(예: `@` 뒤의 숫자)를 부여합니다 [3, 4]. 이 ID는 녹화 세션 중 캡처된 여러 스냅샷 간에 유지되므로 특정 객체의 힙 상태를 정확하게 비교할 수 있게 해줍니다 [3, 4, 15].
|
||||
### 매 응용
|
||||
1. SPA 의 leak detection — page navigate 후 reachable obj 의 monitor.
|
||||
2. React re-render allocation 의 hotspot 식별.
|
||||
3. Worker / animation loop 의 per-frame allocation 의 minimize.
|
||||
4. Stream parser 의 backpressure 검증.
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌:** 자동화 엔진에 의해 매핑된 지식으로, 추후 정밀 검증 필요.
|
||||
- **정책 변화:** Programming & Language 분야의 자동 자산화 수행.
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- **Related Topics:** 힙 스냅샷([[Heap Snapshot]]), 가비지 컬렉션([[Garbage Collection]]), 메모리 누수(Memory Leak)
|
||||
- **Projects/Contexts:** [[Chrome DevTools]], Microsoft Edge DevTools
|
||||
- **Contradictions/Notes:** 소스 간의 모순된 내용은 없으며, [[Chrome DevTools]]와 Microsoft Edge DevTools 등 [[Chromium]] 기반 브라우저 문서들에서 파란색/회색 막대의 의미와 도구의 작동 방식(50ms 주기의 스냅샷 등)을 모두 동일하게 설명하고 있습니다 [3, 4, 7, 8].
|
||||
|
||||
---
|
||||
*Last updated: 2026-04-19*
|
||||
|
||||
---
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
## 💻 패턴
|
||||
|
||||
### Chrome DevTools — Allocation 기록
|
||||
```text
|
||||
# TODO
|
||||
1. Open DevTools → Memory tab.
|
||||
2. Select "Allocation instrumentation on timeline".
|
||||
3. Click ●(record), perform workflow, click ⏹.
|
||||
4. Filter by Constructor / Size.
|
||||
5. Expand stack trace — file:line 의 click → Sources panel.
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### 3-snapshot leak diagnosis
|
||||
```text
|
||||
1. Snapshot 1 (baseline)
|
||||
2. Trigger workflow N times (open modal, close, ...).
|
||||
3. Force GC (trash icon).
|
||||
4. Snapshot 2.
|
||||
5. Repeat workflow N times again, force GC.
|
||||
6. Snapshot 3.
|
||||
7. Filter "Comparison" — objects allocated between Snap1 and Snap2 still alive at Snap3.
|
||||
→ That's the leak.
|
||||
```
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### Programmatic — performance.measureUserAgentSpecificMemory()
|
||||
```javascript
|
||||
if ('measureUserAgentSpecificMemory' in performance) {
|
||||
const result = await performance.measureUserAgentSpecificMemory()
|
||||
console.log(result.bytes) // total bytes
|
||||
console.log(result.breakdown) // per realm/type
|
||||
}
|
||||
```
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### Node.js — heap profiling (built-in inspector)
|
||||
```javascript
|
||||
// node --inspect server.js
|
||||
// Then in chrome://inspect → DevTools → Memory tab
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
// or programmatic
|
||||
import { Session } from 'inspector'
|
||||
const session = new Session()
|
||||
session.connect()
|
||||
session.post('HeapProfiler.startSampling')
|
||||
// ... workload
|
||||
session.post('HeapProfiler.stopSampling', (err, { profile }) => {
|
||||
fs.writeFileSync('heap.heapprofile', JSON.stringify(profile))
|
||||
})
|
||||
```
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
### Detect React leak (common pattern)
|
||||
```jsx
|
||||
// LEAK — interval 의 closure 의 stale state 의 retain
|
||||
useEffect(() => {
|
||||
const id = setInterval(() => setCount(c => c + 1), 1000)
|
||||
// missing cleanup
|
||||
}, [])
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
// FIX
|
||||
useEffect(() => {
|
||||
const id = setInterval(() => setCount(c => c + 1), 1000)
|
||||
return () => clearInterval(id)
|
||||
}, [])
|
||||
```
|
||||
|
||||
### High-frequency allocation reduction
|
||||
```javascript
|
||||
// BAD — every frame allocates
|
||||
function tick() {
|
||||
const v = { x: Math.random(), y: Math.random() } // allocation per frame
|
||||
draw(v)
|
||||
requestAnimationFrame(tick)
|
||||
}
|
||||
|
||||
// GOOD — reuse buffer
|
||||
const v = { x: 0, y: 0 }
|
||||
function tick() {
|
||||
v.x = Math.random()
|
||||
v.y = Math.random()
|
||||
draw(v)
|
||||
requestAnimationFrame(tick)
|
||||
}
|
||||
```
|
||||
|
||||
### WeakMap/WeakRef — GC-friendly cache
|
||||
```javascript
|
||||
const cache = new WeakMap() // GC 의 reclaim 가능
|
||||
function compute(obj) {
|
||||
if (cache.has(obj)) return cache.get(obj)
|
||||
const r = expensive(obj)
|
||||
cache.set(obj, r)
|
||||
return r
|
||||
}
|
||||
```
|
||||
|
||||
### FinalizationRegistry — leak detect in test
|
||||
```javascript
|
||||
const fr = new FinalizationRegistry(name => console.log(`${name} GC'd`))
|
||||
|
||||
function track(obj, name) {
|
||||
fr.register(obj, name)
|
||||
}
|
||||
|
||||
// in test: track(component, 'Modal'); unmount; await gc();
|
||||
// expect Modal GC'd to log
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Tool |
|
||||
|---|---|
|
||||
| Live SPA 의 leak suspect | DevTools Memory → Allocation timeline + 3 snapshots |
|
||||
| Production-like overhead 필요 | Allocation sampling |
|
||||
| Detached DOM hunt | Heap snapshot → "Detached" filter |
|
||||
| Total memory size monitoring | `performance.measureUserAgentSpecificMemory()` |
|
||||
| Node server | `--inspect` + Chrome DevTools, 또는 clinic.js |
|
||||
| Animation hotspot | Allocation timeline (short window) |
|
||||
|
||||
**기본값**: Allocation instrumentation on timeline 의 short (10-30s) recording. 매 3-snapshot 의 leak suspect 시.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Performance Profiling]] · [[Memory Management]]
|
||||
- 변형: [[Heap Snapshot]] · [[CPU Profile]] · [[Performance Timeline]]
|
||||
- 응용: [[Memory Leak Detection]] · [[GC Optimization]]
|
||||
- Adjacent: [[Chrome DevTools]] · [[V8 Engine]] · [[WeakMap]] · [[FinalizationRegistry]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: User 가 "page slow over time" / "memory grows" / "browser crashes after 1h" 의 report 시. 매 Allocation timeline 의 first action.
|
||||
**언제 X**: One-shot CPU bottleneck — 매 Performance panel (CPU profile) 의 prefer.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Snapshot 1개 만 보기**: leak 의 X-prove. 매 minimum 2-3 snapshots 의 compare.
|
||||
- **GC 의 X-force**: snapshot 전 GC button 의 click 의 X-하면 매 noise 의 inflated.
|
||||
- **Production minified code**: source map 의 X-load → stack trace 의 unreadable.
|
||||
- **Long recording**: 100 MB+ 의 allocation timeline 의 DevTools 의 freeze.
|
||||
- **Closures 의 ignore**: 매 detached DOM retainer 의 most-common 한 closure.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Chrome DevTools docs 2026, V8 blog).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — DevTools allocation timeline, 3-snapshot leak hunt, Node profiling |
|
||||
|
||||
Reference in New Issue
Block a user