pendulum
pendulum copied to clipboard
pendulum.parse memory leak
- [x] I am on the latest Pendulum version.
- [x] I have searched the issues of this repo and believe that this is not a duplicate.
- Ubuntu 20.04 -2.1.0 - 2.1.2
Issue
There is a memory leak if pendulum.parse() throws an exception. This started in 2.1.0 and has persisted to 2.1.2.
Leak in 2.1.0 and not 2.0.5:
import pendulum
import psutil
for index in range(1000000):
try:
pendulum.parse("FAIL")
except Exception:
pass
if index % 1000 == 0:
print(f"iteration {index} memory usage {psutil.Process().memory_full_info().rss / 1024} kb")
No leak:
import pendulum
import psutil
for index in range(1000000):
try:
pendulum.parse("2021-04-08 14:23:30")
except Exception:
pass
if index % 1000 == 0:
print(f"iteration {index} memory usage {psutil.Process().memory_full_info().rss / 1024} kb")
This bug has been fixed in #563, however, the latest pypi release 2.1.2 is three year ago. And the C extension has been rewritten in Rust, anyway ... it is fixed in master branch ...