Hi
I am using JNI to get pixel data from an invoked JVM. Unfortunately I am facing serious memory leaks when using the following code to access my byte array.
unsigned char* JVMD3DUpdateFunctions::getPixelData( unsigned char textureIndex )
{
pixelData = (jarray)env->CallObjectMethod( rfdynhudObject, getPixelDataMethod, (jint)textureIndex );
if ( pixelData == NULL )
{
logg( "ERROR: texture pixel data is null." );
return ( false );
}
return ( (unsigned char*)env->GetPrimitiveArrayCritical( pixelData, &isCopy ) );
}
void JVMD3DUpdateFunctions::releasePixelData( unsigned char textureIndex, unsigned char* pointer )
{
env->ReleasePrimitiveArrayCritical( pixelData, (void*)pointer, 0 );
pixelData = NULL;
}
unsigned char* pixels = getPixelData( 0 );
// copy dirty rects
releasePixelData( 0, pixels );
I can guarantee, that no java or JNI call is made between these two calls. I have also verified, that the ‘pixelData’ ponter is the same in both methods.
I don’t see, what I can to differently. What am I doing wrong?
Marvin