We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
Question: Is there a way to manage what is in memory with Processing for multimedia intensive projects pulling from local media? I know the Garbage Collector should be taking care of things automatically but I'm having trouble finding any relevant info on the process outside of small snippets from forum posts like setting unused media variables to NULL and calling System.gc(); manually (which actually causes the program to stop running entirely... assumedly because I need to import a library to know what System is? Is there a FAQ page on memory management? I was unable to find one.). I'm currently running Processing 2.0.3.
Context: I'm working on a multimedia intensive book application in Processing running in JavaScript mode which I then run through PhoneGap to run on iOS and Android devices.
Unfortunately within the iOS universe I am bound to their memory management requirements... so at max it appears I can only have about ~275MB worth of media in memory so unlike running on a full-fledged desktop, loading all the media in setup() (which I am doing now) is out of the question.
I figure at least I would need the current page, previous page, and next page loaded into memory. Any other thoughts on how to do this better?
Thank you!
Answers
System.gc() will do you no good in JS mode, since this is a Java command, acting on the Java garbage collector, not on the JavaScript one...
Memory management in JS and in Java are quite different (common point is that both have a GC). JS offers, AFAIK, little control over the memory management (which depends on the browser, anyway).
Indeed, you can just loose the unused images, keeping in memory only the few ones you need. You must be careful about loading time, to avoid to freeze the application. And to avoid loading too often the images: have safeguards for that.
PhiLho, you are the man (even though you are the bearer of somewhat bad news, haha)! Thank you! (sorry for posting in the wrong forum btw-- I like the descriptions of each subsection you linked-- it makes it much clearer where to post!)