memory and garbage collecting
Important thing is not to lock memory when using objects which are connected to other objects and will be released while still the other object exists.
Example can be this : i have a scene object. In the scene object i put in the list of the scene an car object. The car object also refers back to scene object so it can easily for some reason get there when needed. Cool? Yes, but also makes memory feel bad. The garbage collector will not release the car properly because it is connected to scene which exists until somewhere inside perhaps a game object you disconnect the scene object too. Which is ok until you find out that you spawned between some minutes maybe around 5M objects of cars.
So remember to clean the object when destroyed by disconnecting from scene. object.parent_scene = nil would be enough.
I did some testing and it seems that was the reason of some problems with memory growing. Also there is something like weak table reference (read on lua web about it) and the object class definition i used did not know about that. The weak table when released did not watch if there are any connection to scene and just released the car itself. Which is good i think… ehm, if i did some mistake write on the conversation board under this text.
So long until next time when i find something usefull.
LUA game developing for dumbies
Some nice ways of doing the lua game developing .
Status | In development |
Category | Other |
Author | Bastian |
More posts
- roguelike console57 days ago
- android GPS and other sensor for LOVE2D.58 days ago
- screen flickering65 days ago
- doggie game66 days ago
- leeeerpiiiing is haaard67 days ago
- canvas speedApr 02, 2025
- object inheritanceMar 19, 2025
- exportingMar 08, 2025
- light and shadeMar 07, 2025
Leave a comment
Log in with itch.io to leave a comment.