[issue44310] lru_cache memory leak

2021-06-04 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
assignee:  -> rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44310] lru_cache memory leak

2021-06-04 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
versions:  -Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44310] lru_cache memory leak

2021-06-04 Thread Ken Jin


Ken Jin  added the comment:

@Wouter
Hmm, I thought most use cases of lru_cache benefit from strong references for 
predictable hit rates? I'm not an expert in this area, so I nosied-in someone 
else who is.

However, I noticed that the current doc doesn't mention the strong reference 
behavior anywhere. So I think your suggestion to amend the docs is an 
improvement, thanks!

--
nosy: +kj, rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44310] lru_cache memory leak

2021-06-04 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Using a weak dictionary is not a correct solution as the cache must take string 
ownership of the arguments and return value to do it's job properly. Moreover, 
there are many types in Python that don't support weak references so this will 
be a backwards incompatible change and limiting the cache quite a lot.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44310] lru_cache memory leak

2021-06-04 Thread Joannah Nanjekye


Change by Joannah Nanjekye :


--
nosy: +nanjekyejoannah, pablogsal

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44310] lru_cache memory leak

2021-06-04 Thread Roundup Robot


Change by Roundup Robot :


--
keywords: +patch
nosy: +python-dev
nosy_count: 1.0 -> 2.0
pull_requests: +25122
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/26528

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44310] lru_cache memory leak

2021-06-04 Thread Wouter De Borger


Change by Wouter De Borger :


--
type:  -> resource usage

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44310] lru_cache memory leak

2021-06-04 Thread Wouter De Borger


New submission from Wouter De Borger :

# Problem

the functools.lru_cache decorator locks all arguments to the function in memory 
(inclusing self), causing hard to find memory leaks. 

# Expected  

I had assumed that the lru_cache would keep weak-references and that when an 
object is garbage colected, all its cache entries expire as unreachable. This 
is not the case.

# Solutions 

1. I think it is worth at least mentioning this behavior in de documentation. 
2. I also think it would be good if the LRU cache actually uses weak 
references. 

I will try to make a PR for this.

--
components: Library (Lib)
messages: 395075
nosy: Wouter De Borger2
priority: normal
severity: normal
status: open
title: lru_cache memory leak
versions: Python 3.10, Python 3.11, Python 3.6, Python 3.7, Python 3.8, Python 
3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com