Skip to content

Memory leak when use lru_cache #148459

@tanaliko

Description

@tanaliko

Bug report

Bug description:

memory leak when running code:

from functools import *

@lru_cache(maxsize=100_000)
def f(n):
    if n==1 : return 3
    if n>1:  return 5*f(n-1)

step=995
for n in range(1,10**12,step):
    t=f(n)
    if (n-1)%(step*10)==0:
        print(n,(n*100)/10**12, f.cache_info())

more cache size more fast leak

CPython versions tested on:

3.14

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions