Jump to content

Memory Leak in LUA


Recommended Posts

Using the default FPS template in LUA, I have noticed an excessive amount of memory being used. In debug mode, standing perfectly still, memory usage continues to increase. There are times where it may fall slightly, but overall, after leaving the default FPS project on the pickup items map, the usage went from ~45 MB to 400MB or so over an hour.

Is there any solution to this or is this expected behavior?

Also, I believe the issue lies in the FPSController UpdatePhysics function, after deleting the code inside that function, memory usage stays still. It seems the objects like Vec3 are not being cleared from memory but this is just a guess.

Link to comment
Share on other sites

The way Lua works is it only performs a garbage collection sweep once a certain threshold is reached. To test memory usage you can add a collectgarbage() call in your main loop so it gets collected each frame and run the game in debug mode. (This will result in slower execution speed so it is not recommended to use this all the time.)

(In Ultra Engine the game logic is all running on its own thread and has a full 16 milliseconds to execute, so continual garbage collection could be an option to use there without affecting the framerate.)

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

17 hours ago, Josh said:

The way Lua works is it only performs a garbage collection sweep once a certain threshold is reached. To test memory usage you can add a collectgarbage() call in your main loop so it gets collected each frame and run the game in debug mode. (This will result in slower execution speed so it is not recommended to use this all the time.)

(In Ultra Engine the game logic is all running on its own thread and has a full 16 milliseconds to execute, so continual garbage collection could be an option to use there without affecting the framerate.)

Yes, however, after leaving the program running for a few hours I got Lua Error: Out of Memory.

Also, how can I apply to get access to the Ultra Engine beta?

 

EDIT: I was referring to my own project, my apologies, it's an issue I'm currently solving. Thank you Josh for the response, I am still interested in the beta. Let me know, thanks!

Link to comment
Share on other sites

Okay, that would indicate you probably do have a memory leak. Can you isolate what is causing it? Try disabling parts of your code until it stops happening, together with the call to collectgarbage() in the main loop.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...