LWJGL i10n changes and memory leaks

Started by Matzon, October 28, 2004, 20:33:21

Previous topic - Next topic

Matzon

lo guys

I was having some issues with fmod not being able to open files with odd characters (non ascii). It turns out that the way we retrieve strings from native side is only valid if the environment we're running in is utf8 (Windows XP & Linux apparently is (but still failed with fmod, for no apparent reason).
The fix is to get the bytes instead - I have modified the code to do so: http://lwjgl.org/i10n.patch

Please read more here:
http://java.sun.com/docs/books/jni/html/other.html
section 8.2

If no one objects I will commit (seems to work fine).

While ensuring proper deallocation of stuff I noticed two memory leaks:
Java_org_lwjgl_opengl_GL20_initShaderSource
Java_org_lwjgl_opengl_ARBShaderObjects_initShaderSource

Both methods allocate resources needed, but never free them again. We need to have destruction code for this... How do we do this best?

/matzon

elias

Regarding the leaks: Are they really leaks, and not just a buffer of strings "large enough"?

- elias

Matzon

well the problem is that they're never reclaimed... It's not a *huge* deal since the buffers are small - but they should be free'd somehow instead of relying on the OS to do it on exit.

elias

Well I don't see the big deal really. All the global static variables are not reclaimed either. The difference is the memory area they're allocated in.

- elias

spasi

It's no big deal, yes, but I'll fix it anyway (tonight I hope). It is a, probably unnecessary, way of caching an array of pointers and an an array of ints, which could just as easily be malloced/freed each time.