This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author cryvate
Recipients Wouter De Borger2, cryvate, kj, nanjekyejoannah, pablogsal, python-dev, rhettinger, serhiy.storchaka
Date 2021-06-08.15:42:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1623166927.6.0.473983952895.issue44310@roundup.psfhosted.org>
In-reply-to
Content
Reading this bug thread last week made me realize we had made the following error in our code:


class SomethingView():
    @functools.lru_cache()
    def get_object(self):
        return self._object


Now, as this class was instantiated for every (particular kind of) request to a webserver and this method called (a few times), the lru_cache just kept filling up and up. We had been having a memory leak we couldn't track down, and this was it.

I think this is an easy mistake to make and it was rooted, not so much in hard references though (without that though, it would have not leaked memory) but because of the fact the cache lives on the class and not the object.
History
Date User Action Args
2021-06-08 15:42:07cryvatesetrecipients: + cryvate, rhettinger, python-dev, serhiy.storchaka, pablogsal, nanjekyejoannah, Wouter De Borger2, kj
2021-06-08 15:42:07cryvatesetmessageid: <1623166927.6.0.473983952895.issue44310@roundup.psfhosted.org>
2021-06-08 15:42:07cryvatelinkissue44310 messages
2021-06-08 15:42:07cryvatecreate