-
Notifications
You must be signed in to change notification settings - Fork 112
Closed
Labels
Description
I found this issue after I got a report that GWE was using 1.6 GB after several hours of execution (normally it should be around 100MB).
The problem seems to be that every time a new instance of display.Display() is created, a new type for all the resource classes is generated:
Line 135 in a8df107
| self.display.resource_classes[class_name] = type(origcls.__name__, |
This is a problem if, like in GWE, you want to periodically use an extension and a new instance of Display is created and closed after each invocation.
A simple reproduction script can be found here:
https://github.com/leinardi/python-xlib/blob/memory-leak/leak.py
Top 1 lines
#1: <frozen importlib._bootstrap_external>:487: 398.2 KiB
1903 other: 984.7 KiB
Total allocated size: 1382.9 KiB
Top 1 lines
#1: Xlib/display.py:137: 600.6 KiB
dictionary)
1956 other: 2485.5 KiB
Total allocated size: 3086.1 KiB
Top 1 lines
#1: Xlib/display.py:137: 1435.7 KiB
dictionary)
1960 other: 3467.0 KiB
Total allocated size: 4902.7 KiB
Top 1 lines
#1: Xlib/display.py:137: 2505.5 KiB
dictionary)
1961 other: 4612.2 KiB
Total allocated size: 7117.7 KiB
Top 1 lines
#1: Xlib/display.py:137: 3809.2 KiB
dictionary)
1963 other: 3137.9 KiB
Total allocated size: 6947.1 KiB
Top 1 lines
#1: Xlib/display.py:137: 5347.5 KiB
dictionary)
1963 other: 3597.0 KiB
Total allocated size: 8944.5 KiB
Reactions are currently unavailable