I have a project with other students and we’ve been working on something using the jMonkeyEngine.
Now the thing is the engine runs fine on all of our laptops, pc’s etc. Even on my (not so very good) laptop.
Now when I run the project on my gaming pc it lags sometimes. Like once every 3 seconds i get some framedrops.
(I’m not sure, but I think this experience is from developing OpenGL apps on the Android, not specifically JME).
Are you using a fixed framerate? If not, a higher framerate may make the GC run more often resulting in the spikes you see.
OK. Try locking it to 60 or 90 or whatever framerate you need and see if that helps.
Intuition (that may not be entirely correct down to numbers): An fps of 600 produces x10 as much “garbage” as 60 fps. The GC gets more work to do in the same amount of time resulting in larger spikes, more often.
He means if you want to rotate or move or animate anything (amongst other things) you must multiply it by tpf to avoid framerate dependent speed in favor of time based speed. Otherwise a 500fps client would animate like hyperspeed compared to a client run ing at 60 or 70fps. You utilise tpf (time per frame) to avoid this problem.
It doesnt have much to do with your issue tbh, and if you dont understand you will when you see things moving faster or slower as your frame rate changes.
Not sure if it is the same issue, but I know nvidia cards run an option called “threaded optimization” which can cause frame drops every few seconds. Basically the option offloads the render calls to a separate thread and the frame drop is caused by the synchronization. There is a way to setup the meshes “correctly” for nvidia cards but I haven’t spent the time yet figuring out how to do it in the engine. Setting vsync helped the issue but didn’t completely solve it. I didn’t get clean framefrate until I disabled the threaded optimization.
Slowing down the game (decreasing fps) does not solve the problem but will only delay it. If spikes are created by garbage collection (and I’m pretty sure that they are), you need to rework your code. Don’t create temporary objects, reuse them, avoid using iterators…
Yes I know my teammate has spend the entire day yesterday fixing GC problems. We worked on the project for the entire academy year and tomorrow is our due date … We had to make a drone simulation with objects in the world and our drone has to automatically (with AI) move to the objects using stereovision (so calculating all the objects on its own) in a different thread and recreating the objects in that thread on a different jMonkeyEngine.