LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Matzon on October 28, 2004, 20:33:21

Title: LWJGL i10n changes and memory leaks
Post by: Matzon on October 28, 2004, 20:33:21
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
Title: LWJGL i10n changes and memory leaks
Post by: elias on October 29, 2004, 07:00:27
Regarding the leaks: Are they really leaks, and not just a buffer of strings "large enough"?

- elias
Title: LWJGL i10n changes and memory leaks
Post by: Matzon on October 29, 2004, 07:38:44
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.
Title: LWJGL i10n changes and memory leaks
Post by: elias on October 29, 2004, 08:21:13
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
Title: LWJGL i10n changes and memory leaks
Post by: spasi on October 29, 2004, 08:41:17
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.