A routine that repeatedly evaluates a template could keep a fresh copy of the same condition check in memory on each run. Home Assistant reuses the saved check instead, while still evaluating it with the current values.

In @jgaalen’s controlled comparison, 50,000 additional script runs after 100 warmups left about 53.7 MB of extra live Python allocations before the correction and 36 KB after it. That measures retained program data, not the process’s total memory. The store of reusable checks held 50,100 entries before and one after.

The test used isolated processes without integrations or devices, with one trial per comparison. It demonstrates this leak being eliminated, not that every source of growing memory use in a real installation will disappear.