Help needed: constant memory growing with polymovie

spin lud's icon

MacOS 14.4.1

Max 8.6.2

viddll video engine

Hi guys, I am noticing a constant increase in memory usage with jit.gl.polymovie. I have a folder with about 3 GB of videos but when loading that with polymovie it increase memory usage overtime to 30 GB and more. I don't understand since it is supposed to cache the video files in memory, but why so much more memory then the original size? Also it seems to constant growing in memory usage over time.

Is there anything I can do to prevent this?

Source Audio's icon

don't append but read folder as first measure.

Then check cache settings in both Max Preferences for viddll

and also in js inspector (I have no idea what it is good for,

documentation is a not existing really , what is var cache_sizeauto = 5; ? 5GB ? or 5 liter ....)

Rob Ramirez's icon

video engine viddll is going to consume a lot of memory. You can have some control over that via the cache_size Max preference or the cache_size attritube of polymovie. This value represents GBs of memory and attempts to limit the frame cache size for that particular movie file. If you are load a folder with tons of movies, then these size will all add up and take tons of memory.

avf engine requires less memory in general, whether or not using polymovie. The amount of memory consumed has nothing to do with the file size on disk of files, as the memory stores uncompressed frames.

All that to say, polymovie is not magic and if you are dumping tons of files on it, it will consume memory accordingly.

spin lud's icon

Hi, thanks a lot for your help! So if I understand correctly the cache_size is for the single file and not globally for the whole polymovie object, so if I have cache_size=1 and 60 video files, 60GB of memory will be allocated only for cache is that right? If so, it doesn't seem very scalable. Would not be better to have an overall amount of cache available for the polymovie object instead?

Regarding what SOURCE_AUDIO said, what exactly does @cachemode attribute do exactly and how to use it?

During my tests, after some time of running the pacth I have reached 70 GB of memory usage, from a folder of overall size of 3 GB (70 videos). This seems a lot! Do uncompressed frames take so much space in memory?

I am using viddll because I had problems using avf with polymovie. I am not sure why but when loading the same video folder with avf it caused the program to hangs and I had to force-quit Max.

Again, thanks for helping!

Source Audio's icon

Only way I can reproduce growing memory is to repeatedly

append that same folder with movies.

I suspect this here:

read movie folder once and play as much as you want,

shows no significant memory increase for me.

maybe you overlooked this first line of my first response

"don't append but read folder as first measure."

spin lud's icon

I had already moved from appendfolder to readfolder in my tests, that didn't change much because appendfolder was done only once at loadbang in any case (so same outcome as readfolder)

Source Audio's icon

I really did compare both, and each time I appended same folder, Max memory

increased.

keeping readfolder and caches set to 0, made it stay stable.

On max 8.6.2, Highh Sierra, viddll.

Robert Ramirez's icon

Do uncompressed frames take so much space in memory?

yup!