Hi all,
So here’s the situation.
I have a network of objects stored as a few arrays in a C++ JNI library. I expose that network data to my Java application through DirectByteBuffers. I wrap the ByteBuffers up in a class with a flyweight pattern, like:
public class Network {
private ByteBuffer nodes;
public class Node {
private int index;
private int offset = NODE_SIZE + index;
public int index( int index ) {
this.index = index;
}
public float x() {
return nodes.getFloat( offset + X_OFFSET );
}
public float y() {
return nodes.getFloat( offset + Y_OFFSET );
}
}
}
Life was good. Or so I thought.
The problem I’m seeing, is that the access to the buffers seems very slow. I’m accessing, on average, about 50K nodes, and my times can run up into the seconds. Anybody seen this before?
I’m running with JDK 1.5 Beta 1, with -server and more than enough memory allocated. I give the server plenty of time to warm up before taking measurements.
God bless,
-Toby Reyelts