New issue 2855: PyDateTimeAPI->DateTime_FromDateAndTime https://bitbucket.org/pypy/pypy/issues/2855/pydatetimeapi-datetime_fromdateandtime
Anya Tchernishov: Calling `ciso8601.parse_datetime` with pypy3 leaks memory. Tested in CentOS 7 docker image with pypy3 installed: ``` $ pypy3 --version Python 3.5.3 (fdd60ed87e941677e8ea11acf9f1819466521bf2, May 24 2018, 06:31:10) [PyPy 6.0.0 with GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] ``` ``` $ cat /etc/redhat-release CentOS Linux release 7.4.1708 ``` This code shows the leak (`main.py`): ``` import ciso8601 while True: iso_formatted_timestamp = '2018-07-07T14:06:07.560279-05:00' datetime_timestamp = ciso8601.parse_datetime(iso_formatted_timestamp) ``` Command used: `pypy3 main.py` Expected behaviour: - memory consumption of the pypy3 process doesn't grow over time Actual behaviour: - memory consumption growing rapidly (~35MB increase each second) Cpython doesn't leak for this code. In addition, this the code leaks only when the timestamps timezone is not UTC. Calling `ciso8601.parse_datetime` with timestamp in UTC timezone doesn't leak. The following C code reproduces the leak: ``` datetime = PyImport_ImportModule("datetime"); fixed_offset = PyObject_GetAttrString(datetime, "timezone"); static PyObject * _parse(PyObject *self, PyObject *args, int parse_any_tzinfo) { PyObject *obj; PyObject *tzinfo = Py_None; tzinfo = PyObject_CallFunction( fixed_offset, "N", PyDelta_FromDSU(0, 60 * 60, 0)); #define LEAK 1 #if LEAK obj = PyDateTimeAPI->DateTime_FromDateAndTime( 2017, 1, 1, 1, 1, 1, 1, tzinfo, PyDateTimeAPI->DateTimeType); #elif obj = PyDateTimeAPI->Time_FromTime(1, 1, 1, 1, tzinfo, PyDateTimeAPI->TimeType); #endif Py_DECREF(tzinfo); return obj; } ``` `DateTime_FromDateAndTime` leaks while `Time_FromTime` doesn't. _______________________________________________ pypy-issue mailing list pypy-issue@python.org https://mail.python.org/mailman/listinfo/pypy-issue