Hi community,
I am trying to prevent memory leaks and I'm finding strange results. I thought maybe you have an idea about it.
I think I am following good practices.
So here is my situation :
The situation
In my scene, on scene Enter I am creating 200 objects, 3 times (with a timer so 3 x 200) and those objects are falling.
Those objects are Shapes, and I attached a body to each shape.
I have applied linear velocity to those bodies.
The setup is very simple.
When I click on my "restart" button, my scene is destroyed and recreated, visually everything is good the restart functionality works.
Stable Garbage count
When my scene is empty, the garbage count is 880.
Each time I "restart" my scene after all objects have been added to the stage (timer count = 3), my garbage count reverts to a number that stays stable (let's say 890).
Even after 10 restart, garbage count is still 890.
Note : I was surprised it was not 880.If I understand well, that means that each time I am cleaning the scene I'm not leaving anything behind (removing timer, body, shape).
Which is good.
Note : If it was leaking, the count would not be stable and most likely would be increasing each time. Right?
Garbage count "levels"
When I modify the timer's count to be 6 and wait for all objects to be added to the stage, the scene is cleaned but the garbage count is now 910.
Each time I clean the scene,
even after 10 reset, the count remains stable at 910.
Note : Again, my understanding was that cleaning everything would take me back to 880...
The issue
If I restart my scene while only a few objects have been added...
if I don't wait that the timer is called 6 times and only a few objects appeared on screen, the garbage's count stays at 910 (does not decrease to a lower level).
Garbage Count "levels?"
My conclusion is that each time the number of objects added to stage reaches a certain number, the garbage count reaches a new level that remains stable (but can't decrease) until the number of objects reaches a higher level once again (in which case it increases).
Below is an example
:::::::::::::::::::::::::::::::::::::::
Steps below are done chronologically
:::::::::::::::::::::::::::::::::::::::
0 object | garbage count = 880
10 objects | garbage count = 890
100 objects | garbage count = 900
10 objects | garbage count = 900
1000 objects | garbage count = 930
10 objects | garbage count = 930
Questions
- Have you experienced that situation?
- What could be the cause for this?
- What would you suggest me to check?