public static void main(String[] args) {
if (!glfwInit()) {
throw new IllegalStateException("Unable to initialize GLFW");
}
long window = createWindow();
for (int i = 0; i < 10; i++) {
LOG.info("iteration {}", i);
try {
Thread.sleep(100); // allowing logging to flush
} catch (InterruptedException ie) {
}
GLFW.glfwDestroyWindow(window);
window = createWindow();
GLFW.glfwPollEvents();
GLFW.glfwSwapBuffers(window);
}
LOG.info("normal exit");
}
private static long createWindow() {
long window = glfwCreateWindow(640, 480, "title", NULL, NULL);
glfwMakeContextCurrent(window);
glfwShowWindow(window);
return window;
}
GLFW.glfwPollEvents()
--------------- S U M M A R Y ------------
Command Line: -Djdk.module.main=dev.flowty.trace dev.flowty.trace/dev.flowty.trace.Main
Host: AMD Custom APU 0405, 8 cores, 14G, Steam Runtime 2 (soldier)
Time: Tue Oct 21 21:54:24 2025 IST elapsed time: 1.040722 seconds (0d 0h 0m 1s)
--------------- T H R E A D ---------------
Current thread (0x00007fb63002c110): JavaThread "main" [_thread_in_native, id=31412, stack(0x00007fb637500000,0x00007fb637600000) (1024K)]
Stack: [0x00007fb637500000,0x00007fb637600000], sp=0x00007fb6375f9bd0, free space=998k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [gameoverlayrenderer.so+0x499b9]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j org.lwjgl.system.JNI.invokePV(JJ)V+0 org.lwjgl@3.3.6+1
j org.lwjgl.glfw.GLFW.glfwSwapBuffers(J)V+17 org.lwjgl.glfw@3.3.6+1
j dev.flowty.trace.Main.main([Ljava/lang/String;)V+65 dev.flowty.trace@0.0.1-SNAPSHOT
v ~StubRoutines::call_stub 0x00007fb622537cc6
QuoteMemoryStack stack = MemoryStack.create(capacity).push(); {This will work, but it's wasteful (a GC-managed ByteBuffer is allocated internally). I would recommend sticking to the default stack for everything, except the extension properties array. This is what LWJGL does now:
//use stack
} stack.pop();
try (VkExtensionProperties.Buffer extensions = VkExtensionProperties.malloc(capacity)) {
// ...
}