docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
This commit is contained in:
@@ -0,0 +1,165 @@
|
||||
---
|
||||
id: wiki-2026-0508-electron-v8-memory-cage
|
||||
title: Electron V8 Memory Cage
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [V8 Sandbox, V8 Pointer Compression Cage, Electron Memory Limit]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [electron, v8, security, memory, sandbox]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: javascript
|
||||
framework: electron
|
||||
---
|
||||
|
||||
# Electron V8 Memory Cage
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 V8 의 4GB virtual address cage"**. 매 V8 의 pointer compression (32-bit offset within 4GB cage) 의 introduction 의 each isolate 의 4GB heap limit 의 hard cap 의 impose. 매 Electron 의 main + renderer + utility process 의 each 의 separate cage 의 hold. 매 2026 년 의 V8 의 sandbox 의 default-on 의 spectre/heap-corruption mitigation 의 standard.
|
||||
|
||||
## 매 핵심
|
||||
|
||||
### 매 cage 구조
|
||||
- **4GB virtual region** per V8 isolate.
|
||||
- **32-bit compressed pointer** (relative to cage base).
|
||||
- **All heap allocations** must fit inside cage.
|
||||
- **External buffer (ArrayBuffer backing)** can live outside (with sandbox checks).
|
||||
|
||||
### 매 Electron implication
|
||||
- 매 main process: 매 4GB cap.
|
||||
- 매 renderer process: 매 4GB cap each (per BrowserWindow).
|
||||
- 매 utility process: 매 separate cage.
|
||||
- 매 large data → utility process 또는 native module.
|
||||
|
||||
### 매 응용
|
||||
1. Heavy LLM inference UI (chunk via utility process).
|
||||
2. Video editor (native module for frame buffers).
|
||||
3. Multi-window archive viewer (split heaps per window).
|
||||
4. Out-of-process computation (worker_threads / utilityProcess).
|
||||
|
||||
## 💻 패턴
|
||||
|
||||
### Diagnose hitting cage limit
|
||||
```javascript
|
||||
const v8 = require('v8');
|
||||
const stats = v8.getHeapStatistics();
|
||||
console.log({
|
||||
total_heap_size_mb: stats.total_heap_size / 1024 / 1024,
|
||||
heap_size_limit_mb: stats.heap_size_limit / 1024 / 1024, // ~4GB
|
||||
external_memory_mb: stats.external_memory / 1024 / 1024,
|
||||
});
|
||||
```
|
||||
|
||||
### utilityProcess for off-cage work (Electron 25+)
|
||||
```javascript
|
||||
const { utilityProcess } = require('electron');
|
||||
|
||||
const child = utilityProcess.fork(path.join(__dirname, 'heavy-worker.js'), [], {
|
||||
serviceName: 'pdf-parser',
|
||||
// own V8 cage, own 4GB
|
||||
});
|
||||
child.postMessage({ task: 'parse', path: '/big.pdf' });
|
||||
child.on('message', (result) => { /* handle */ });
|
||||
```
|
||||
|
||||
### worker_thread (lighter, but shares process limits)
|
||||
```javascript
|
||||
const { Worker } = require('worker_threads');
|
||||
|
||||
const worker = new Worker('./inference-worker.js', {
|
||||
resourceLimits: { maxOldGenerationSizeMb: 3500 }
|
||||
});
|
||||
worker.postMessage({ tokens });
|
||||
worker.on('message', (output) => { /* ... */ });
|
||||
// NOTE: each worker has its own V8 cage
|
||||
```
|
||||
|
||||
### Native addon for >4GB buffers
|
||||
```cpp
|
||||
// node-addon-api: allocate outside V8 heap
|
||||
#include <napi.h>
|
||||
Napi::Value AllocLargeBuffer(const Napi::CallbackInfo& info) {
|
||||
size_t bytes = info[0].As<Napi::Number>().Int64Value();
|
||||
void* ptr = malloc(bytes); // outside V8 cage
|
||||
// wrap in ArrayBuffer with external backing store
|
||||
return Napi::ArrayBuffer::New(info.Env(), ptr, bytes,
|
||||
[](Napi::Env, void* data) { free(data); });
|
||||
}
|
||||
```
|
||||
|
||||
### Disable pointer compression (escape cage — NOT recommended)
|
||||
```bash
|
||||
# Only for dev / specific embedding; loses sandbox + perf
|
||||
electron --js-flags="--no-pointer-compression" .
|
||||
# Production: prefer process split
|
||||
```
|
||||
|
||||
### Memory-aware streaming pattern
|
||||
```javascript
|
||||
// Don't load 3GB JSON into V8 — stream + chunk
|
||||
const { pipeline } = require('stream/promises');
|
||||
const fs = require('fs');
|
||||
const { Transform } = require('stream');
|
||||
|
||||
await pipeline(
|
||||
fs.createReadStream('big.ndjson'),
|
||||
new Transform({
|
||||
transform(chunk, _, cb) {
|
||||
// process chunk — never accumulate full
|
||||
cb();
|
||||
}
|
||||
}),
|
||||
);
|
||||
```
|
||||
|
||||
### Per-window heap monitor
|
||||
```javascript
|
||||
mainWindow.webContents.on('render-process-gone', (event, details) => {
|
||||
if (details.reason === 'oom') {
|
||||
log.error('Renderer OOM — likely cage exhausted');
|
||||
relaunchWindow();
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| < 1GB working set | Single renderer, no special handling |
|
||||
| 1-3GB | Monitor + GC pressure tuning |
|
||||
| 3-4GB approaching | utilityProcess 분리 |
|
||||
| > 4GB single dataset | Native addon + external buffer |
|
||||
| Many concurrent heavy ops | Multiple utilityProcess (each 4GB) |
|
||||
|
||||
**기본값**: 매 utilityProcess 의 split — 매 sandbox + cage 의 multiplication.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[V8 Engine]] · [[Electron]]
|
||||
- 변형: [[Chrome V8 Heap Analysis]]
|
||||
- Adjacent: [[Pointer Compression]] · [[V8 Sandbox]] · [[Garbage Collection]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 OOM crash diagnosis. 매 cage limit 의 explanation. 매 process-split refactor.
|
||||
**언제 X**: 매 V8 internal flag 의 latest 는 V8 release notes 의 verify.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Bigger `--max-old-space-size` only**: 매 4GB cap 의 hit. 매 size 만 의 늘림 의 X.
|
||||
- **Single-renderer 의 모든 work**: 매 cage 의 single 의 exhaust. 매 split.
|
||||
- **External buffer 의 forget GC**: 매 native addon 의 finalizer 의 mandatory.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (V8 pointer compression docs, Electron process model docs, V8 sandbox RFC).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — V8 cage / Electron process split |
|
||||
Reference in New Issue
Block a user