We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
I have built an application that uses image sequences, my issue is however, that the application is very memory hungry. It works pretty well on the iMac I have been developing on however when I try to run it on a mac mini (2012) which is where it will need to run, it is unusable because of lag.
Are there ways to optimize memory management or clear the cache etc so that the memory does not get clogged up?
(I have already upped the RAM in preferences to 4gb) Even on my desktop which is technically far better spec that the iMac I have serious issues with frame rates and RAM usage.
Any help is much appreciated! Will
Answers
you can force the garbage collector to work
also show your code
;-)
Oh? How do I go about doing that?
Ok ill post code, was bit reluctant to just due to sheer amount of it. :/
Java doesn't have a mechanism to manually release object allocated memory!
Most we can do is get rid of ALL references and await for Java's GC do its job when it feels like to! :-<
In order to accomplish that, pay attention which fields, arrays and other data structures are keeping track on those references. Lest object memories will linger forever and eventually you'll get outta RAM! :-SS
I have cut out the irrelevant parts of the application (OSC and Leap motion stuff). The remainder relating the the loading of images is below ...
@GoToLoop oh dear! appears its a bit late for that for me ;)
I have just found something in my code however that has helped greatly, I had for some stupid reason set the framerate to 50 fps. Having now set it to 30 its much smoother and less laggy, not munching through RAM quite as angrily either, seems to be leveling out about 2-3gb. (Still a lot for 1 image sequence is it not?!)
Function image() likes to cache PImage objects, especially when using OpenGL renderers like P2D & P3D!
Even when you clear them when you loadImage() new 1s into images[], old 1s still linger in Processing's canvas!
Even though that cache eventually empties, it can take some time. And if you loadImage() faster than that cache empties, you end up w/ stuffed RAM!
Perhaps you should search this forum for image cache clear or something. It'll force memory release faster! o=>
I thought I had resolved the problem which I had with this but it appears not! I tried clearing the cache using g.removeCache(img); but it doesn't appear to do anything?
It will run fine with 1 image sequence loaded but then each time I switch I have to wait 8 odd seconds to load a new one so am trying to load them all into memory so I can switch seamlessly between them or is there a way to optimise loading so that I don't have long wait times? my issue is the image sequence plays forwards and backwards through sequence depending on user input so it doesn't really allow me to load say 50 odd images ahead of where I currently am in the sequence as its unpredictable. HELP :-SS