Hi all,
I have a problem with a memory corruption during glfwTerminate. When I run this program and press esc to exit I get this:
Renderer.destroy: 1
malloc(): memory corruption
The problem goes away if I don't create and destroy the Buffer object so I guess it has something to do with that. But I can't figure out what's wrong. I'm using lwjgl 3.2.1.1 on Linux
All the code (minimized as much as I could):
https://gist.github.com/McJty/69a7130ce54caf765434c3af865d1b1a
Thanks in advance
Look at your Buffer.init() method. You free the verticesBuffer twice by calling memFree(verticesBuffer) twice.
private void init() {
FloatBuffer verticesBuffer = MemoryUtil.memAllocFloat(vertices.length);
verticesBuffer.put(vertices).flip();
vaoId = glGenVertexArrays();
glBindVertexArray(vaoId);
vboId = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vboId);
glBufferData(GL_ARRAY_BUFFER, verticesBuffer, GL_STATIC_DRAW);
memFree(verticesBuffer); // <- FREE HERE!!!
glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
if (verticesBuffer != null) { // <- is true
MemoryUtil.memFree(verticesBuffer); // <- AND HERE!!!
}
}
Oh thanks. I totally missed that