Recent posts

#11
General Java Game Development / Re: CPU load and FPS decrease ...
Last post by rakeshjogi - January 08, 2026, 08:15:43
I agree with you. If you are frequently creating temporary objects, this action may quickly overwhelm the garbage collector. In your case as you say you are frequently creating temp objects like FloatBuffer during each matrix calculation.  This will definitely cause GC pauses and CPU/FPS spikes, exactly as you observed.

As you pointed out, your workaround of minimizing heap movement and constraining the young generation memory is more of a temporary patch than a sustainable solution.

For long-term optimization, reducing object churn (especially in the render loop) is key. Reusing buffers, pooling objects, or switching to off-heap/native memory when appropriate can dramatically reduce GC overhead.
It clearly explains how memory is managed in Java, why large object allocation or frequent temporary allocations lead to performance hits, and what GC does during a pause.

Also, suppose if you want to understand your GC behavior better, then try analyzing your GC  logs using GCeasy. It helps you with visualizing the memory usage, GC durations, and object promotions, which can reveal spikes and inefficiencies much more clearly than VisualVM alone.
#12
Hi, I'm a complete newbie to Java, and I need a bit of a friendly shove to get me started, if someone could be so kind. 

I've tried to find a tutorial, or sample piece of code for what I am trying to do, but I'm either too blind, or too stupid to find what I'm after.

All I want is a bit of code to draw my game map as an isometric grid (hell, right now, I'd just settle for a straight 2D chessboard!).  I've got a 2D array, and I want to be able to map it to a window, and allow scrollbars.

Does anyone know of some source code for this, or a tutorial?

You'd be helping an idiot to begin to figure out where his feet are.  Thanks a bundle!

Geometry Dash Lite
#13
General Java Game Development / Optimizing LWJGL 3 Performance...
Last post by earthworm - November 06, 2025, 02:22:34
Hi everyone,
I've been experimenting with LWJGL 3 for a new rendering project and noticed that performance can vary drastically when integrating with modern GPU APIs like Vulkan or Metal (via MoltenVK).

I'm trying to understand the best practices for optimizing LWJGL 3-based applications — particularly in areas like:

Reducing CPU-GPU synchronization overhead

Managing multiple threads for rendering and resource loading

Efficient memory allocation for vertex buffers and textures

If anyone has experience benchmarking LWJGL 3 performance or can share profiling tools or code-level tweaks, I'd love to discuss and learn from your insights.

Thanks in advance for your advice and time!
That's Not My Neighbor
#14
Bug Reports / RFE / Segfault, but only when runnin...
Last post by ryanm - October 21, 2025, 21:14:29
This is the most cornery of corner cases, but I'm experiencing a segfault that only happens when I run my game via steam, and on linux.
It can be reliably triggered by changing the display parameters that require me to tear down and recreate the window - you can do this with no issue up to three times, but the fourth will provoke a segfault.

I've cut things down to this minimal case:

  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;
  }

If I run that directly from the IDE, it completes normally. If I run it from steam (which presumably brings steam's overlay stuff into play), it'll segfault on the 4th iteration.

Interestingly, commenting out the
GLFW.glfwPollEvents()
call allows normal exit - no segfault is provoked.

I'd like to attach the hs_err_pid file, but that provokes an error from the forum. The summary of the dump is:
---------------  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

Can anyone spot what I'm doing wrong?

Cheers!
#15
Lightweight Java Gaming Library / Re: Crash during allocation of...
Last post by cpope9141 - September 01, 2025, 13:18:16
Thank you for your help, spasi!
#16
Lightweight Java Gaming Library / Re: Crash during allocation of...
Last post by spasi - September 01, 2025, 08:15:51
No timeline yet. I think you only need lwjgl-vulkan.jar and it should work fine with the 3.3.6 core. However, I don't see a reason to not switch to 3.4.0-snapshot altogether. LWJGL snapshots are very stable due to its nature: most changes happen in the bindings & native libraries and those are always stable releases.

QuoteMemoryStack stack = MemoryStack.create(capacity).push(); {
//use stack
} stack.pop();
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:

try (VkExtensionProperties.Buffer extensions = VkExtensionProperties.malloc(capacity)) {
  // ...
}
This does explicit malloc/free.
#17
Do you have a timeline for when the 3.4.0-snapshot will be upgraded to release? If not soon, how much of a risk would it be for me to use the snapshots of lwjgl.jar and lwjgl-vulkan.jar in their current state?
#18
So, I need to set the stack capacity with something like:

MemoryStack stack = MemoryStack.create(capacity).push(); {
//use stack
} stack.pop();

The above seems to be working for me, but I'd be happy for someone to double check that I am not misusing something.
#19
Lightweight Java Gaming Library / Re: Crash during allocation of...
Last post by spasi - August 31, 2025, 21:14:21
That's the same bug, just in your code instead of inside LWJGL. VkExtensionProperties is a relatively big struct (260 bytes), so 252 such structs make it easy to overflow the default MemoryStack size (64kb).
#20
I have updated lwjgl.jar (with natives) to 3.4.0-snapshot. Before updating my Nvidia driver, the game continued to work (as expected). After updating the driver, I see a crash and this stack trace:

Exception in thread "main" java.lang.OutOfMemoryError: Out of stack space.
    at org.lwjgl.system.MemoryStack.nmalloc(MemoryStack.java:321)
    at org.lwjgl.vulkan.VkExtensionProperties.malloc(VkExtensionProperties.java:208)
    at org.lwjgl.vulkan.VkInstance.getAvailableDeviceExtensions(VkInstance.java:82)
    at org.lwjgl.vulkan.VkInstance.getInstanceCapabilities(VkInstance.java:45)
    at org.lwjgl.vulkan.VkInstance.<init>(VkInstance.java:29)
    at renderer.vulkan.VulkanInstance.create(VulkanInstance.java:77)
    at renderer.RendererCore.create(RendererCore.java:238)
    at renderer.Renderer.create(Renderer.java:544)
    at game.Game.run(Game.java:47)
    at game.Game.main(Game.java:15)

If I also update lwjgl-vulkan.jar to 3.4.0-snapshot, I continue to see a crash, but it is past the vulkan instance creation during physical device selection:

Exception in thread "main" java.lang.OutOfMemoryError: Out of stack space.
    at org.lwjgl.system.MemoryStack.nmalloc(MemoryStack.java:321)
    at org.lwjgl.vulkan.VkExtensionProperties.malloc(VkExtensionProperties.java:200)
    at renderer.vulkan.physicalDevice.PhysicalDevice.checkDeviceExtensionSupport(PhysicalDevice.java:156)
    at renderer.vulkan.physicalDevice.PhysicalDevice.meetsRequirments(PhysicalDevice.java:234)
    at renderer.vulkan.physicalDevice.PhysicalDevice.selectPhysicalDevice(PhysicalDevice.java:119)
    at renderer.RendererCore.create(RendererCore.java:239)
    at renderer.Renderer.create(Renderer.java:544)
    at game.Game.run(Game.java:47)
    at game.Game.main(Game.java:15)

I am using "try(MemoryStack stack = stackPush())" to create the stack passed into VkExtensionProperties.malloc. It appears that the capacity being requested from the stack at the time of the crash is only (252 * SIZEOF).