GLSL Shader usage: Memory usage increasing, then render lags


while writing an app which has a custom number of geos moving around the scene, I was facing a shader/memory problem.

All objects get the same vertex shader and if I run the application after a few seconds the rendering lags each 30secs. How often it lags is depending on the number of geos in the scenegraph.

Well, at moment of the rendering lag the memory usage falls down from its top to the half or something - also depending on the number of geos. Then the memory usage starts increasing again until it will be cutted again.

I also tested the GLSL jME shader demo and I got the same result. Memory increasing till 78-80MB and then cutted to 42-44MB. If you are moving the mouse all the time you will see that there is the same rendering lag I described at the moment of the memory cut.

Does anybody know if it is a jME or LWGL problem?

I tested it on a Win XP with ATI Radeon 9600 and another Win XP machine with a ATI 9800 PRO. Mac wasnt tested because of missing GLSL Support in OS X (which should be in development)

The memory issue is probably jME. It looks like every update creates a new Iterator object and some Buffers… I’ll do some tests and see if I can eliminate that.

Yep, that was the issue. The code was creating an Iterator and one new buffer per ShaderUniform on every update! All fixed up and checked into CVS. It looks like the memory now stabalizes at a fixed level as you would expect. Please give it a whirl and thank you for bringing it to our attention.

^^^ oh - forgot to login :slight_smile:

Hmm, well if you run the demo, you’ll see the mem is solid. So there must be something else going on in your app. As for your other issue, can you tell me what uniform types you are using?

It is only about two uniforms that are set on each update (25fps) for each object as you can see below

        shader.setUniform("time", time + timeOffset);
        shader.setUniform("speed", speed * 250 * target.length());

Ok, found out what was wrong with my fix and checked it in… Rewrote the GLSL test temporarily on my side to dynamically alter the size of the bricks and tested… No more object creation when changing uniforms and changing uniform values works as well. Please test though :slight_smile:

yeah - everything works fine (even with 200 objects :wink: ). solid memory and updating uniforms :smiley:

thanks a lot

NP. Good to hear! Thanks again for bringing it up.


Sorry for my ugly GLSL contribution :// it’s my fault.


No worries, new code in any project always has one or two rough edges to file down. :slight_smile: