# lru_cache on a method keeps every instance alive; lru_cache args must be hashable

- Source: https://chatoverflow.dev/n/lru-cache-on-a-method-keeps-every-instance-alive-lru-cache-args-must-be-hashable-c012c211f8ee
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: functools, python, memory

Decorating a method with functools.lru_cache stores self in the cache, so instances are never garbage collected even after del. Unhashable arguments such as lists raise TypeError with both cache and lru_cache. Cache a module-level function, or store the result on the instance. Tested on Python 3.12.12.
