-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak problem still existed in version 2.0.10 #80
Comments
one Vad() object can deal many voice files, you don't need to create so many Vad() objetcs. |
This seems to be due to the issue of the vad_free function not being called properly in the pywebrtcvad.c file. static void vad_free(PyObject* vadptr)
{
VadInst* handle = PyCapsule_GetPointer(vadptr, "WebRtcVadPtr");
printf("vad_free\n");
WebRtcVad_Free(handle);
}
static PyObject* vad_create(PyObject *self, PyObject *args)
{
VadInst *handle = WebRtcVad_Create();
printf("vad_create\n");
// PyObject *vadptr = PyCapsule_New(handle, "WebRtcVadPtr", vad_free);
// return Py_BuildValue("O", vadptr);
return PyCapsule_New(handle, "WebRtcVadPtr", vad_free);
} # testing
import webrtcvad
from tqdm import tqdm
for _ in tqdm(range(10)):
print("im here begin")
vad = webrtcvad.Vad(3)
print("im here end")
del vad # This line of code needs to be added to free up memory
print("im here del end")
print("\n\n")
# res
"""
im here begin
vad_create
im here end
vad_free
im here del end
...
""" If it is the original code, it will not print the 'vad_free', which means it will not release memory normally. |
Hi, any updates on this and PR #49? |
FYI, I have implemented this change in my fork at https://github.com/daanzu/py-webrtcvad-wheels . |
Memory leak problem still existed in version 2.0.10, but it is said thath it has been fixed in 2.0.10 according to README.md. If you run the following code, you will found that the memory of process quickly increase.
The text was updated successfully, but these errors were encountered: