Author ncoghlan
Recipients ncoghlan, rhettinger, serhiy.storchaka, thesheep
Date 2013-12-04.12:15:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CADiSq7f4728tAAOz-t2HDFu3dRA=STXbB_cKXawnCThophokXQ@mail.gmail.com>
In-reply-to <1386152120.21.0.486045339018.issue19859@psf.upfronthosting.co.za>
Content
On 4 December 2013 20:15, Radomir Dopieralski <report@bugs.python.org> wrote:
> But I think it's would be still worthwhile to add a note to the lru_cache's documentation, saying something like:
>
> """
> Warning! lru_cache will keep references to all the arguments for which it keeps cached values, which prevents them from being freed from memory when there are no other references. This can lead to memory leaks when you call a function with lru_cache on a lot of short-lived objects.
> """

Umm, that's part of the operational definition of a value based cache
- it needs to keep things alive, so that if a different instance shows
up with the same value, it will still get a cache hit.

We're willing to put warnings in the docs for cases where it's easy to
inadvertently introduce a security vulnerability, but not for
situations like this where using a container inappropriately may cause
it to keep objects alive that you didn't intend to keep alive.
History
Date User Action Args
2013-12-04 12:15:28ncoghlansetrecipients: + ncoghlan, rhettinger, serhiy.storchaka, thesheep
2013-12-04 12:15:28ncoghlanlinkissue19859 messages
2013-12-04 12:15:28ncoghlancreate