Memory leak with textures?

I'm wondering if I may have run into a potential memory leak while working with textures. Basically, I have a thread that generates cloud textures in real-time and stores the textures in an ArrayList. The textures are used in real-time, so the ArrayList acts as a buffer and never contains more than 20 textures.



As a test (and to reproduce the error), I currently have my thread just creating and deleting textures:


Texture cloudTex = generateCloudTexture();
skyTexturePool.add(cloudTex);
Texture testTex = skyTexturePool.get(0);
skyTexturePool.remove(0);
TextureManager.deleteTextureFromCard(testTex);



After around 3,000 iterations, I receive the following error:

Exception in thread "Thread-9" java.lang.OutOfMemoryError: Direct buffer memory
at java.nio.Bits.reserveMemory(Bits.java:633)
at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:95)
at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:288)
at com.jme.util.geom.BufferUtils.createByteBuffer(BufferUtils.java:850)
at com.jme.util.TextureManager.loadImage(TextureManager.java:675)
at com.jme.util.TextureManager.loadTexture(TextureManager.java:432)
at com.jme.util.TextureManager.loadTexture(TextureManager.java:423)
at Utility.generateCloudTexture(Utility.java:296)
at java.lang.Thread.run(Thread.java:613)

Is this a memory leak or am I doing something wrong?

-Prime

Jme2 does not free native ressoures as far as I know, so genreating textures on the fly might not be a good idea.



(Why not passing the generate texture method a texture objects and modify it instead, but I'm not sure if that will really help, but i guess so)

But Prime is using TextureManager.deleteTextureFromCard(testTex);.

Wouldn't that delete it from OpenGL memory as well?

I still don't know what method to use to delete textures from OpenGL memory, it seems nobody really knows.