Skip to content
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

Possible memory leak #18

Closed
jamiewannenburg opened this issue Feb 22, 2014 · 4 comments
Closed

Possible memory leak #18

jamiewannenburg opened this issue Feb 22, 2014 · 4 comments

Comments

@jamiewannenburg
Copy link

Hi,
I need to process a lot of videos, but not many at a time. However I keep running into memory issues, even after upgrading hardware. I think I have tracked down the issue and any help would be appreciated.

It appears that the ffmpeg_reader/writer stays open even if a clip is deleted. Here is an example:

import psutil
from moviepy.editor import *
import time

initial_set = psutil.get_pid_list()

clip = VideoFileClip("sync_test2/1/GOPR0185.MP4", audio=False)
new_set = psutil.get_pid_list()
new_ps = set(new_set)-set(initial_set)
print new_ps

for new_p in new_ps:
    p = psutil.Process(new_p)
    print p.name
    print p.get_memory_percent()

del clip

time.sleep(2) # give subprocess time to close the processes

check_set = psutil.get_pid_list()
for new_p in new_ps:
    if new_p in check_set:
        print str(new_p) + " is still open!"

When I run this I get:

set([19228, 19229])
ffmpeg
1.26245461454
ffmpeg
0.0
19228 is still open!
19229 is still open!

So my questions are: Is it possible to explicitly close the reader/writer after I am done with a clip? Is there a different way to delete a the clip? Is this a bug? Is there a different way for me to test this?

I can also try to fix this in my fork if you can point me to a good place to start.
Thanks.

@Zulko
Copy link
Owner

Zulko commented Feb 22, 2014

Will fix it partially in the next commit. In the meantime try

clip.reader.close_proc()

This completely closes/deletes the subprocess associated with the clip. I guess you don"t even have to do del clip after that.

@jamiewannenburg
Copy link
Author

Awesome, thank you. Will do as soos as I get a chance.

@jamiewannenburg
Copy link
Author

Thanks, that works great. However I had to change it too clip.reader.close() but I might be working on an older commit or PIP install.

@Zulko
Copy link
Owner

Zulko commented Feb 23, 2014

Cool. Yeah I still change the names regularly. I also cleaned a lot of the code, so I think contributing directly will become easier in the future :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants