performance-profiling
Diagnose and improve WPF performance for the widget host app: UI virtualization, async usage, rendering cost, memory leaks, and profiling workflow. Use when investigating slow startup, laggy UI, or high memory usage.
📖 中文导读:Diagnose and improve WPF performance for the widget host app: UI virtualization, async usage, rendering cost, memory leaks, and profiling workflow. Use when investigating slow startup, laggy UI, or high memory usage. 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。
name: performance-profiling description: Diagnose and improve WPF performance for the widget host app: UI virtualization, async usage, rendering cost, memory leaks, and profiling workflow. Use when investigating slow startup, laggy UI, or high memory usage.
Performance Profiling
Overview
Keep the shell and widgets responsive by profiling UI, async work, and memory usage.
Definition of done (DoD)
- No
.Resultor.Wait()on async calls from UI thread - Lists with >50 items use VirtualizingStackPanel
- Event handlers/timers disposed when views unload
- Startup time measured and tracked (target: <2s to usable)
- Memory usage profiled for leaks after opening/closing widgets
Workflow
- Reproduce the performance issue with a minimal scenario.
- Profile UI thread usage and rendering cost.
- Check data bindings and virtualization settings.
- Validate async usage and background work.
- Inspect memory growth and leaks.
UI performance
- Use
VirtualizingStackPanelfor lists and grids. - Disable heavy effects in scrolling regions.
- Prefer
BitmapCachefor static visuals when beneficial.
Async guidance
- Offload IO and compute to background tasks.
- Avoid blocking the UI thread with
.Resultor.Wait(). - Use cancellation tokens for long-running operations.
Memory and leaks
- Remove event handlers and timers when views unload.
- Avoid long-lived static references to views or VMs.
- Use weak event patterns for global notifications.
References
references/virtualization.mdfor list and items control setup.references/async-patterns.mdfor UI-safe async usage.references/memory-leaks.mdfor leak detection tips.