This may be a ‘stupid’ idea, but I am attempting to use Nifty to create a short animated ‘flipbook’ movie. Basically I am asking Nifty to quickly load and display images to create a old-school animation. I have the animation actually working but the memory usage is a problem. I have 140 JPEG images totaling 12 MB on the hard drive but when the application runs the memory usage increases until it’s nearly 1GB by the end of the movie. Of course it runs on my desktop computer but my laptop at school only has 800 MB free memory with all the other school applications running on it. I was hoping to use this in a presentation at school so I’m forced to use these computers.
So my question is - is this normal? It seems to me that maybe Nifty isn’t cleaning out the resources for the old frames when I load a new one? The memory usage climbs as each frame is loaded. I have combed through my code and I am not keeping references to the resources in my code. I even tried calling System.gc() garbage collection to no avail. Is there anything I can do in NIfty to get it to release the resources? I read that Nifty uses a reference system to keep previously loaded images in cache - can I turn this off? Is this the issue? The memory usage for this 1 minute video just seems really high.
Have you tried using standard scenegraph elements and exchanging the texture?
Nifty’s primary mission isn’t animations, and it is not very good at holding up outside its normal domain.
Are you using the latest version of JME? There were some massive shader-related improvements to Nifty recently.
I think they should be in RC2 but I haven’t followed that closely enough to say for sure.
I actually was considering converting the project over to textures painted on the scenegraph. I originally wanted to use Nifty because additional elements could be added to the frames as desired (a dialog box for instance). I will probably start looking into converting it over to that soon.
It all actually works quite well - the frames load nice, the dialog boxes work well, etc. It just uses a huge amount of memory! I was hoping there would be a Nifty.dispose() to clean unused Images out. I have tried calling dispose() on the individual images themselves but it doesn’t work. Made me start wondering if there are references to the images hanging around Nifty somewhere. Tried the NiftyDisplay.clean() routine but that didn’t appear to make a difference either.
I am using jME Platform 3.0 RC2 - as far as I can tell that’s the latest. It claims all the updates are installed. Thanks for the help!