General (Read-only)

OpenGLES buffers memory consumption
kotiachiy
Hello, i'm developing a GL ES application for Android using my G3 D858/857 and i noticed an unusual memory consumption when creating GL buffers: the amount of RAM consumed after creating and initializing it is exactly 2 times bigger that it's size. Here is my code:

logMem("before buff creation");

ByteBuffer dummyBuff = ByteBuffer.allocateDirect(1024 * 1024 * 16).order(ByteOrder.nativeOrder());

byte[] some = new byte[1024];
for (int i = 0; i < dummyBuff.capacity(); i+= some.length) {
dummyBuff.put(some);
}

dummyBuff.rewind();

logMem("buff data created");

int[] bufferHandles = new int[1];
GLES20.glGenBuffers(1, bufferHandles, 0);
int bufferHandle = bufferHandles[0];

GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, bufferHandle);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, dummyBuff.capacity(), dummyBuff, GLES20.GL_STATIC_DRAW);

logMem("buff data supplied");

After execution my log says following:

20:13:34.243 V/mem: before buff creation, mem 1381
20:13:34.466 V/mem: buff data created, mem 1366
20:13:34.500 V/mem: buff data supplied, mem 1334

As you see, between 2 last records there was 32M of RAM lost, despite the size of data i was supplying via a buffer was only 16M. My question is: is this a bug, or, if not, why is it happening? I tried contacting Qualcomm as the chip manufacturer, but was redirected here, as they don't provide support on issues with consumer devices, so, any help would be very appreciated.
Posted on 16-Mar-2017
jasonsmith

Re:OpenGLES buffers memory consumption

Thanks for sharing.I found a lot of interesting information here. A really good post, very thankful and hopeful that you will write many more posts like this one.
UC Browser SHAREit MX Player


Posted on 16-Nov-2018
Navigation