Generally it's probably not a good idea to load a video clip inside draw. I'd consider having an array of GLMovie objects, instantiating them all in setup, and calling play or loop at them - one at a time - inside draw. When the clip is no longer used you could try to call movie.stop(), movie.close().
You could try to also set movie = NULL and afterwards force garbage collection with System.gc() - but that's a bit of black magic I don't know much myself.
@GoToLoop
I was suggesting an array of instances - in this case you might actually want to destroy one by setting it to null, no superstition. dispose() is an internal, undocumented method. And yes, pause().
@gohai@GoToLoop thanks for your input!
the issues i see are related to gpu memory.
for the moment i test with a total of four .mp4 video snippets, ~ 2.5mb each.
i think, when instantiating them within setup(), they immediately want to live in gpu ram. i'm on rpi3, so i got ~1000mb. i dedicated 256mb to gpu to get rid of memory related errors.
then i tried the dynamic loading/disposing thing from within draw().
it works, but i have no idea for how long because:
during runtime i keep an eye on taskmanager. there are two tasks named "java".
i think they both live in gpu ram and both tend to grow. (the one i suspect to hold the sketch goes over 80mb, just by loading/disposing a total of 10mb of .mp4's.)
in the end i want to use ~100mb of snippets which only makes sense with some sort of dispose thing.
i've put the load/dispose part in an extra thread now. working!.
i have to think about an array, but i don't want to call snippets by filename. just put them all in a folder and pick randomly by something like "*.mp4"!?
@GoToLoop Please rethink the language you use in the forum. It's not useful to label other people's suggestion as stupid, or dumb. (Just makes me want to not spend any more time in this forum.)
If you had actually taken the time to read my initial comment, you would have understood my proposed sequence as:
I gave an example pinpointing exactly what I meant by my generic rant.
Which obviously wasn't your case, @gohai! Sorry about that! X_X
About your last example above, it presumes the array was fill up w/ instances of GLMovie within setup().
It also presumes that the sketch had that much RAM available.
Therefore I don't see much logic to dispose()/close() any of those GLMovie later in draw().
Just a simple pause() will do. Later on, if that same GLMovie is needed again, just call play() for it.
If some1 can't afford to load all those GLMovie files, or just wanna keep the RAM usage low, it needs to constantly dispose() a GLMovie before loading a new 1. :-B
Answers
What's the exact issue you're seeing?
Generally it's probably not a good idea to load a video clip inside
draw
. I'd consider having an array ofGLMovie
objects, instantiating them all insetup
, and callingplay
orloop
at them - one at a time - insidedraw
. When the clip is no longer used you could try to callmovie.stop()
,movie.close()
.You could try to also set
movie = NULL
and afterwards force garbage collection withSystem.gc()
- but that's a bit of black magic I don't know much myself.Let us know what worked in the end!
native
gstreamer_close() method.movie = null;
"obligatory" step is bullocks superstition! And it'snull
, notNULL
.@GoToLoop I was suggesting an array of instances - in this case you might actually want to destroy one by setting it to
null
, no superstition.dispose()
is an internal, undocumented method. And yes,pause()
.If we're filling up that array at setup(), the best approach is pause() a GLMovie rather than dispose() &
null
it.What I ranted about was the superstition case below:
Given variable movie was about to get assigned another instance right way, assigning it to
null
1st was dumb! :O)Your library seems to follow the API names from Processing's Video library. Am I right?
https://Processing.org/reference/libraries/video/index.html
native
. And Java's GC can't deallocate something written in another language!@gohai@GoToLoop thanks for your input! the issues i see are related to gpu memory. for the moment i test with a total of four .mp4 video snippets, ~ 2.5mb each. i think, when instantiating them within setup(), they immediately want to live in gpu ram. i'm on rpi3, so i got ~1000mb. i dedicated 256mb to gpu to get rid of memory related errors. then i tried the dynamic loading/disposing thing from within draw(). it works, but i have no idea for how long because: during runtime i keep an eye on taskmanager. there are two tasks named "java". i think they both live in gpu ram and both tend to grow. (the one i suspect to hold the sketch goes over 80mb, just by loading/disposing a total of 10mb of .mp4's.) in the end i want to use ~100mb of snippets which only makes sense with some sort of dispose thing.
i've put the load/dispose part in an extra thread now. working!.
i have to think about an array, but i don't want to call snippets by filename. just put them all in a folder and pick randomly by something like "*.mp4"!?
@GoToLoop Please rethink the language you use in the forum. It's not useful to label other people's suggestion as stupid, or dumb. (Just makes me want to not spend any more time in this forum.)
If you had actually taken the time to read my initial comment, you would have understood my proposed sequence as:
What here is stupid superstitious redundancy?
I gave an example pinpointing exactly what I meant by my generic rant.
Which obviously wasn't your case, @gohai! Sorry about that! X_X
About your last example above, it presumes the array was fill up w/ instances of GLMovie within setup().
It also presumes that the sketch had that much RAM available.
Therefore I don't see much logic to dispose()/close() any of those GLMovie later in draw().
Just a simple pause() will do. Later on, if that same GLMovie is needed again, just call play() for it.
If some1 can't afford to load all those GLMovie files, or just wanna keep the RAM usage low, it needs to constantly dispose() a GLMovie before loading a new 1. :-B