apicici / cimgui-love

LÖVE module for Dear ImGui obtained by wrapping cimgui with LuaJIT FFI.
MIT License
76 stars 6 forks source link

Huge and long lag spikes #5

Closed semyon422 closed 2 years ago

semyon422 commented 2 years ago

There are large (up to hundreds of ms) and long (10-20 frames) lag spikes, probably caused by garbage collection of ImageDatas and Meshes. I did not manage to achieve this in the new project, but in my current project these lag spikes are noticeable even if I open the imgui demo window. The solution for me was to manually free the Meshes and create a new ImageData only when needed. You can check the changes in my fork, maybe you will find a better solution to this problem, but mine suits me. https://github.com/apicici/cimgui-love/blob/1c18d59a5d586b413d1ea51f49beaa4e077c6bab/src/love.lua#L229 https://github.com/apicici/cimgui-love/blob/1c18d59a5d586b413d1ea51f49beaa4e077c6bab/src/love.lua#L231 The love2d wiki doesn't recommend calling these functions every frame.

apicici commented 2 years ago

I haven't noticed any lag spikes on my system, but this is a great suggestion. I implemented a similar approach to what you did, but I went one step further by also avoiding recreating the mesh itself.