T
TheOne
I have a small library of native functions. When I use the library, I
notice that the virtual memory size of java process keeps increasing to
the point that the system's OOM killer is invoked.
Following is the most frequently executed portion of my code:
jbyteArray jbaKey =
static_cast<jbyteArray>(env->GetObjectField(jobjUpdateRec, key_fid));
jbyte *arrKey1 = env->GetByteArrayElements(jbaKey, NULL);
char *arrKey2 = (char *)¤tKey;
if(blEnableRecordLevelLogging)
syslog(...);
for( int i = 0; i < sizeof(reckey_t); i++)
{
arrKey1 = (jbyte)arrKey2;
}
env->ReleaseByteArrayElements(jbaKey, arrKey1, 0);
Initially I was using JNI_COMMIT instead of 0 at the last argument for
env->ReleaseByteArrayElements() which was responsible for the leak.
Even after I changed it I am observing memory leak so I suspect that I
am doing something wrong in my code. Maybe I am supposed to free the
jbaKey. But I don't know how to do that and also not sure whether it is
required. Please advise.
Thank in advance
Sudarshan
notice that the virtual memory size of java process keeps increasing to
the point that the system's OOM killer is invoked.
Following is the most frequently executed portion of my code:
jbyteArray jbaKey =
static_cast<jbyteArray>(env->GetObjectField(jobjUpdateRec, key_fid));
jbyte *arrKey1 = env->GetByteArrayElements(jbaKey, NULL);
char *arrKey2 = (char *)¤tKey;
if(blEnableRecordLevelLogging)
syslog(...);
for( int i = 0; i < sizeof(reckey_t); i++)
{
arrKey1 = (jbyte)arrKey2;
}
env->ReleaseByteArrayElements(jbaKey, arrKey1, 0);
Initially I was using JNI_COMMIT instead of 0 at the last argument for
env->ReleaseByteArrayElements() which was responsible for the leak.
Even after I changed it I am observing memory leak so I suspect that I
am doing something wrong in my code. Maybe I am supposed to free the
jbaKey. But I don't know how to do that and also not sure whether it is
required. Please advise.
Thank in advance
Sudarshan