dotnet-gc-memory
БесплатноБез исполняемых скриптовНе проверенTuning GC and memory. GC modes, LOH/POH, Gen0/1/2, Span/Memory deep patterns, ArrayPool, profiling.
от wshaddix★ 94 звезды на GitHubОб этом скилле
dotnet-gc-memory
Garbage collection and memory management for .NET applications. Covers GC modes (workstation vs server, concurrent vs non-concurrent), Large Object Heap (LOH) and Pinned Object Heap (POH), generational tuning (Gen0/1/2), memory pressure notifications, deep Span
Out of scope: Span
Cross-references: [skill:dotnet-performance-patterns] for Span
GC Modes and Configuration
Workstation vs Server GC
| Aspect | Workstation | Server |
|---|---|---|
| GC threads | Single thread | One thread per logical core |
| Heap segments | Single heap | One heap per core |
| Pause latency | Lower | Higher (more memory scanned) |
| Throughput | Lower | Higher |
| Default for | Console apps, desktop | ASP.NET Core web apps |
<!-- In the .csproj file -->
<PropertyGroup>
<ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup>
// Or in runtimeconfig.json
{
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
}
}
Concurrent vs Non-Concurrent GC
| Mode | Behavior | Use when |
|---|---|---|
| Concurrent (default) | Gen2 collection runs alongside application threads | Latency-sensitive (web APIs, UI) |
| Non-concurrent | Application threads pause during Gen2 collection | Maximum throughput, batch processing |
{
"runtimeOptions": {
"configProperties": {
"System.GC.Concurrent": true
}
}
}
DATAS (Dynamic Adaptation to Application Sizes) -- .NET 8+
DATAS dynamically adjusts GC heap size based on application memory usage patterns. It is enabled by default in .NET 8+ Server GC mode. DATAS reduces memory footprint for applications with variable load by shrinking the heap during low-activity periods.
{
"runtimeOptions": {
"configProperties": {
"System.GC.DynamicAdaptationMode": 1
}
}
}
Set to 0 to disable DATAS if you observe excessive GC frequency in steady-state workloads.
GC Regions -- .NET 7+
Regions replace the older segment-based heap management. Each region is a small, fixed-size block of memory that the GC can allocate and free independently. Regions are enabled by default in .NET 7+ and improve:
- Memory return to the OS after usage spikes
- Heap compaction efficiency
- Server GC scalability on high-core-count machines
No configuration is needed -- regions are the default. To revert to segments (rarely needed):
{
"runtimeOptions": {
"configProperties": {
"System.GC.Regions": false
}
}
}
Generational GC (Gen0/1/2)
How Generations Work
| Generation | Contains | Collection frequency | Collection cost |
|---|---|---|---|
| Gen0 | Newly allocated objects | Very frequent (milliseconds) | Very cheap (small heap) |
| Gen1 | Objects surviving Gen0 | Frequent | Cheap |
| Gen2 | Long-lived objects | Infrequent | Expensive (full heap scan) |
Objects promote from Gen0 to Gen1 to Gen2 as they survive collections. The GC budget for Gen0 is tuned dynamically -- when Gen0 fills, a Gen0 collection triggers.
Tuning Principles
- Minimize Gen0 allocation rate -- reduce temporary object creation on hot paths. Every allocation contributes to Gen0 pressure.
- Avoid mid-life crisis -- objects that live just long enough to promote to Gen1/Gen2 but then become garbage are the most expensive. They survive cheap Gen0 collections and require expensive Gen2 collections to reclaim.
- Reduce Gen2 collection frequency -- Gen2 collections cause the longest pauses. Use object pooling, Span
, and value types to keep long-lived heap allocations low.
Monitoring Generations
# Real-time GC metrics
dotnet-counters monitor --process-id <PID> \
--counters System.Runtime[gen-0-gc-count,gen-1-gc-count,gen-2-gc-count,gc-heap-size]
// Programmatic GC observation
var gen0 = GC.CollectionCount(0);
var gen1 = GC.CollectionCount(1);
var gen2 = GC.CollectionCount(2);
var totalMemory = GC.GetTotalMemory(forceFullCollection: false);
var memoryInf
Установить dotnet-gc-memory в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл dotnet-gc-memory?
Tuning GC and memory. GC modes, LOH/POH, Gen0/1/2, Span/Memory deep patterns, ArrayPool, profiling.
Как установить скилл dotnet-gc-memory?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл dotnet-gc-memory запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic