I meet a memory leak when using ray to do parallel computing. To narrow down the causes, I remove all the codes from the python script except below:
import ray
print("just a blank script")
there are still memory leak errors:
==8279== 54 bytes in 1 blocks are definitely lost in loss record 1,697 of 10,519
==8279== at 0x4C30EDB: malloc (vg_replace_malloc.c:309)
==8279== by 0x4F23592: PyObject_Malloc (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4F5EAE9: PyUnicode_New (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4F675F0: _PyUnicodeWriter_PrepareInternal (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4F3806E: PyUnicode_DecodeUTF8Stateful (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4F7A9F7: ??? (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4F7AFFC: ??? (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4F876AD: _Py_BuildValue_SizeT (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x40BA46D: PyInit_setproctitle (setproctitle.c:174)
==8279== by 0x5053281: _PyImport_LoadDynamicModuleWithSpec (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x5053584: ??? (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4FAF706: PyCFunction_Call (in /usr/lib64/libpython3.6m.so.1.0)
==8279==
==8279== 56 bytes in 1 blocks are definitely lost in loss record 3,102 of 10,519
==8279== at 0x4C30EDB: malloc (vg_replace_malloc.c:309)
==8279== by 0x4F23592: PyObject_Malloc (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4F3BB5C: _PyObject_GC_Malloc (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4F4242D: _PyObject_GC_NewVar (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4F5645E: PyTuple_New (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4FD85E8: ??? (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4FD8B18: ??? (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4FD872E: ??? (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4FD8B18: ??? (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4FD872E: ??? (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4FD965C: ??? (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4FDCAA0: ??? (in /usr/lib64/libpython3.6m.so.1.0)
==8279==
==8279== 64 bytes in 1 blocks are definitely lost in loss record 3,891 of 10,519
==8279== at 0x4C30EDB: malloc (vg_replace_malloc.c:309)
==8279== by 0x40141AD: dl_open_worker (in /usr/lib64/ld-2.28.so)
==8279== by 0x5E79AB6: _dl_catch_exception (in /usr/lib64/libc-2.28.so)
==8279== by 0x401365D: _dl_open (in /usr/lib64/ld-2.28.so)
==8279== by 0x55B81B9: dlopen_doit (in /usr/lib64/libdl-2.28.so)
==8279== by 0x5E79AB6: _dl_catch_exception (in /usr/lib64/libc-2.28.so)
==8279== by 0x5E79B52: _dl_catch_error (in /usr/lib64/libc-2.28.so)
==8279== by 0x55B8938: _dlerror_run (in /usr/lib64/libdl-2.28.so)
==8279== by 0x55B8259: dlopen@@GLIBC_2.2.5 (in /usr/lib64/libdl-2.28.so)
==8279== by 0x502DE19: _PyImport_FindSharedFuncptr (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x5053239: _PyImport_LoadDynamicModuleWithSpec (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x5053584: ??? (in /usr/lib64/libpython3.6m.so.1.0)
==8279==
==8279== 144 bytes in 1 blocks are definitely lost in loss record 7,610 of 10,519
==8279== at 0x4C30EDB: malloc (vg_replace_malloc.c:309)
==8279== by 0x4F23592: PyObject_Malloc (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4FCF8B2: PyCode_New (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x89FE769: __pyx_pymod_exec__raylet(_object*) (in /root/.local/lib/python3.6/site-packages/ray/_raylet.so)
==8279== by 0x502C2F2: PyModule_ExecDef (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x502C381: ??? (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4FAF706: PyCFunction_Call (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4FF3C41: _PyEval_EvalFrameDefault (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4F3FBE7: ??? (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4F795DF: ??? (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4FBDA31: ??? (in /usr/lib64/libpython3.6m.so.1.0)
==8279== by 0x4FEDA69: _PyEval_EvalFrameDefault (in /usr/lib64/libpython3.6m.so.1.0)
I use below command to do memory test:
PYTHONMALLOC=malloc valgrind --leak-check=full -v --track-origins=yes \
--log-file=$SCRIPT_DIR"/algrind_pytest.log" \
--show-possibly-lost=no \
python test.py
My environment:
python3.6.8
valgrind 3.15.0
ray1.12.1/2.3.1
Anyone can help?
I want to know the reason of the memory leak. If it is not a problem, how to remove the error reports.