linux - OSError: [Errno 12] Cannot allocate memory from python subprocess.call -


i've read several similar posts on issue none seem me directly. if duplicate post, please direct me thread containing solution!

i'm saving bunch of images , calling ffmpeg on them subprocess.call. number of times collections of different images. i'm doing:

from subprocess import call video in videos:   call(['ffmpeg', ..., '-i', video, video+'.mp4')]) 

in isolation works fine. however, when have other processing done before these calls (not within loop, literally holding values in memory before loop starts), crashes memory error after having made several of videos (actually while making last one). according this comment, subprocess.call forks/clones current process, seems mean requests memory allocation equal how have in memory, seems way overkill want in calling ffmpeg.

how can call ffmpeg within python without asking allocate unnecessary amounts of memory?

while true subprocess.call fork process, , child process have own memory space identical parent process (your python program), modern operating systems use copy-on-write memory. memory overhead of forked process relatively small, requiring few kb of memory in kernel process accounting. it's not until child process starts making changes memory memory required.

after forking, child process spawned subprocess.call call 1 of exec system calls, loads ffmpeg memory , starts executing it.

furthermore, fork mechanism create new process on posix system (see here), don't think there's alternative fork-then-exec sequence subprocess.call implements.

you may try running program through strace or valgrind see system call not getting memory requests. may determine how lower memory requirements.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -