wpf-rule-freezable-performance — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited wpf-rule-freezable-performance (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Rules for using Freeze() on WPF Freezable objects to maximize rendering performance.
Call Freeze() on every Freezable after it is fully configured and before it is used for rendering.
Applies to: Brush, Pen, Geometry, Transform, PathGeometry, GradientBrush, ImageBrush, DrawingGroup, and all other Freezable subclasses.
| Without Freeze | With Freeze |
|---|---|
| Object tracked for change notifications | No change tracking overhead |
| Cannot be shared across threads | Sharable across all threads |
| WPF retains full change-event infrastructure | Infrastructure freed immediately |
| Higher memory footprint | Minimal memory footprint |
Frozen objects are immutable. WPF can cache and reuse them across render passes without defensive copies.
// Incorrect: brush created but never frozen
protected override void OnRender(DrawingContext dc)
{
var brush = new SolidColorBrush(Colors.CornflowerBlue);
var pen = new Pen(brush, 2.0);
dc.DrawRectangle(brush, pen, new Rect(0, 0, 100, 50));
}
// Correct: freeze immediately after configuration
protected override void OnRender(DrawingContext dc)
{
var brush = new SolidColorBrush(Colors.CornflowerBlue);
brush.Freeze();
var pen = new Pen(brush, 2.0);
pen.Freeze();
dc.DrawRectangle(brush, pen, new Rect(0, 0, 100, 50));
}Creating Freezable objects inside OnRender allocates on every paint cycle. Create them once in the constructor (or a lazy initializer), freeze them, then reuse the frozen instances in every OnRender call.
public class MyVisual : FrameworkElement
{
private readonly SolidColorBrush _fillBrush;
private readonly Pen _borderPen;
public MyVisual()
{
_fillBrush = new SolidColorBrush(Colors.CornflowerBlue);
_fillBrush.Freeze();
_borderPen = new Pen(Brushes.DarkBlue, 1.5);
_borderPen.Freeze();
}
protected override void OnRender(DrawingContext dc)
{
// No allocation here — reuse frozen instances
dc.DrawRectangle(_fillBrush, _borderPen, new Rect(0, 0, ActualWidth, ActualHeight));
}
}If a property changes and a new brush is needed, create and freeze the replacement, then call InvalidateVisual() once.
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.