set_data_array takes memory and never frees it
I am using MemoryData layer to run in test phase. Multiple calls to set_input_arrays in a for-loop seems to take more and more memory unless I reconstruct the net by caffe.Net after some iterations. Why is this happening?
One clue is that less memory is taken with smaller batch size, which is kinda expected...
I have the same issue, have you managed to solve it?
No... I just reload the network after every 100 calls to that function
I found the solution, the reason memory data layer does not release memory is because in Net_SetInputArrays function of _caffe.cpp file, the creation of data_arr and labels_arr object will increase the reference count of corresponding python objects, but in the end of this function it does not decrease it back, which causes memory leak when you update the python objects. The solution is add
Py_DECREF(data_arr);
Py_DECREF(labels_arr);
at the end of this function. Reference:
https://jianfengwang.wordpress.com/tag/python-numpy-cc/
Closing according to #5528.