I think the pointers returned by JNI NewGlobalRef be allocated using GC_malloc_uncollectable. The way it is now, if you store one of these in malloced space (as opposed to GC_malloced space) the garbage collector may come along and think it is free to take it.