JVM pinning support

hi

Can anyone tell me, how I can know about a JVM’s pinning support? Which JVMs support pinning?

I want to use the cheapest approach for handling a Direct3D texture’s byte data in Java. I have a C-plugin, that creates a Direct3D texture and invokes a JVM (standard Sun JVM 1.6) and forwards the texture’s byte data to the JVM. I would like to avoid nio ByteBuffer, since it doesn’t work well with a BufferedImage. I discovered the possibility to communicate through a simple primitive byte array. But it will only work without copying, if the JVM supports pinning. And I don’t know, how to get to know about it. I guess, the internal array format won’t be a problem, since I am using byte arrays.

Marvin

If you’re using BufferedImage somewhere I imagine you’re not too bothered about absolute performance here anyway - have you actually identified a performance bottleneck passing data to the GPU?

Cas :slight_smile:

I have not yet gotten the whole code path to work because of Visual C++ compile problems with the jni binding. But I know from my work on the Xith HUD (OpenGL), that the major two performance bottlenecks are pushing the data back to the graphics card and drawing through a BufferedImage, if it is backed by a ByteBuffer. I avoid drawing on a Graphics2D as much as I can and compute as small dirty rects as I can. But if the BufferedImage was backed by a primitive byte array, it would be extremely fast (I have checked that). Hence I would love to use primitive byte arrays. But for that to work I would need pinning support from the JVM.

Marvin

IIRC in JNI you have these global references, that prevent the JVM from moving them around.

(And are notorious for causing memory leaks).

Let me know if you got it working. I’m very interested, because it would allow for a whole slew of nice things.