dotnet-gc-memory

Configure .NET GC modes and optimize memory allocation with Span and pooling.

1|Updated Feb 22, 2026
One-click install
npx skills add https://github.com/rudironsoni/dotnet-agent-harness --skill dotnet-gc-memory-rudironsoni
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-gc-memory
Source: https://github.com/rudironsoni/dotnet-agent-harness/tree/main/.rulesync/skills/dotnet-gc-memory
Command: npx skills add https://github.com/rudironsoni/dotnet-agent-harness --skill dotnet-gc-memory-rudironsoni

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers understand and tune the .NET Garbage Collector (GC) and memory management strategies to improve application performance and reduce memory footprint.

Core Features & Use Cases

  • GC Tuning: Configure GC modes (Workstation/Server, Concurrent/Non-concurrent) and understand generational heap behavior (Gen0/1/2).
  • Memory Optimization: Learn to use Span<T>, Memory<T>, ArrayPool<T>, and MemoryPool<T> effectively to minimize allocations and LOH/POH fragmentation.
  • Use Case: A high-traffic web API is experiencing performance issues due to frequent GC pauses. This Skill provides guidance on switching to Server GC, optimizing object pooling, and reducing allocations on hot paths to resolve the bottlenecks.

Quick Start

Configure the .NET application to use Server Garbage Collection by adding the ServerGarbageCollection property to the project file.

Frequently Asked Questions about dotnet-gc-memory

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize .NET Garbage Collection for a high-traffic web API?

To optimize .NET Garbage Collection, configure Server GC in your project file and reduce allocations on hot paths using ArrayPool<T> to minimize Gen2 collections and pause times.

What's the best way to reduce LOH fragmentation in .NET applications?

Reduce Large Object Heap (LOH) fragmentation by minimizing large allocations using Span<T> and Memory<T> structures, and by reusing buffers with ArrayPool<T> or MemoryPool<T>.

How do I configure Server Garbage Collection in a .NET project?

Configure Server Garbage Collection by adding the ServerGarbageCollection property to your .NET project file, enabling multi-processor optimized GC modes for high-throughput workloads.

When should I use Span<T> and Memory<T> for memory optimization?

Use Span<T> and Memory<T> for memory optimization when processing data streams or buffers, as they provide allocation-free slicing and access to contiguous memory regions without creating new objects.

What is the difference between Workstation GC and Server GC in .NET?

Workstation GC is optimized for client applications with a single heap, while Server GC creates a separate heap and thread per CPU for high-traffic server applications to maximize throughput.

Why does my .NET application experience frequent GC pauses?

Frequent GC pauses in .NET applications are typically caused by excessive memory allocations on hot paths triggering frequent generational collections, which can be resolved by tuning GC modes and implementing object pooling.