Skip to content

Python3.11 memory usage is more #131538

@RasnaT

Description

@RasnaT

Bug report

Bug description:

After upgrading to Python3.11.11 it is seen that most of the scripts are taking more memory compared to previous version 3.10.16.

is this a bug or expected behavior due to new adaptive interpreter?

Below is an example script run with redis and iproute, where ~4MB memory increase is seen.

python3 -m memory_profiler testmem.py
Running Python Version: 3.10.16 (main, Feb 20 2025, 10:49:09) [GCC 8.4.0]
Filename: testmem.py

Line # Mem usage Increment Occurrences Line Contents
 3     21.2 MiB     21.2 MiB           1   @profile
 4                                         def do_stuff():
 5     21.2 MiB      0.0 MiB           1       import sys
 6     21.2 MiB      0.0 MiB           1       python_version = sys.version
 7     21.2 MiB      0.0 MiB           1       print(f"Running Python Version: {python_version}")
 8     25.8 MiB      4.6 MiB           1       import redis
 9     35.6 MiB      9.8 MiB           1       import pyroute2

2:

python3 -m memory_profiler testmem.py
Running Python Version: 3.11.11 (main, Mar 12 2025, 15:15:10) [GCC 8.4.0]
Filename: testmem.py
Line # Mem usage Increment Occurrences Line Contents
 3     23.8 MiB     23.8 MiB           1   @profile
 4                                         def do_stuff():
 5     23.8 MiB      0.0 MiB           1       import sys
 6     23.8 MiB      0.0 MiB           1       python_version = sys.version
 7     23.8 MiB      0.0 MiB           1       print(f"Running Python Version: {python_version}")
 8     29.1 MiB      5.4 MiB           1       import redis
 9     40.0 MiB     10.9 MiB           1       import pyroute2

Redis version is 4.5.5
pyroute2 version is 0.7.5
OS:Linux controller 5.15.178

CPython versions tested on:

3.11

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixesperformancePerformance or resource usage

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions