Hi,
I am doing some tests on my device (ipod Touch 5th generation).
This is a simple application, but it's slow (= small lag after touch event) on my device compared to the simulator on my mac.
When I touch some objects, it takes some time for the button to react.
Quick Sum-up
collectGarbageCount -> 750 (stable)
wifi hotspot -> a
little bit slow connection
Obviously I thought about the difference of power between the ipod vs Mac.
But I want to check all the hypothesis.
Wifi connection?
I am on a slow connection (wifi hotspot). It is not
that slow though, I can stream some music.
Is it possible that slowness is due to that connection? (I won't have access to a faster connection for a few days/weeks to test myself).
Memory usage too high?
My garbage count is around 750 and is stable (so I thought I am not running out of memory).
Is that number reasonable?
I use :
print (math.floor(collectgarbage("count"))) |
What else should I check?
What could be the other causes?
Thank you
Comments
Likes: Mells
http://www.nightspade.com
On my Mac : 2012.09.09 (will update as soon as I have access to a faster connection)
On my device : 2012.09.09
When I have a lot of objects on screen, FPS are ~30fps (Again, I don't know what is a reasonable amount) but the lag is noticeable even around ~40fps.
I use that code from @techdojo to check the FPS count.
(When removing an object, don't call collectgarbage right away. It will totally lag.)
Another reason is if you're using sql. Saving too much will slow down much.
I can't think of other reason. Those two is the main reason of my past game-lag experience.
Likes: Mells
I am really surprised this could be the reason, I will post the results if that works.
How did you find out? Did you get help on this forum?
For the record, community, can I get your opinion on the following :
- What is an acceptable fps count?
- What is an acceptable garbage count?
- What would be an reasonable amount of garbage collection? Is that possible to estimate it by ourselves?
thank you
I'm using 30 fps.
60 fps is good, yes. But after some testing over time. It's not that good. (Sometime it will also stress out the eyes, if not properly maintained)
For me, garbage count limit is around 15000. (I will call garbage collection if it reach that number)
Edit: I never really check fps eachtime. I just check the things with how good it was on my eyes.
Likes: Mells
Lua uses the mark and sweep garbage collection algorithm exclusively. This has the advantage that we don't have to reference count objects and so don't get cyclic referencing problems. A disadvantage is that the algorithm takes time to process and can be an issue in realtime applications.
Basically calling garbagecollect when removing scene is ok, but calling it on every enterframe is not
thanks for the explanation.
And now I'm giving you the opportunity to post your 2000th comment
Can you give me your opinion on this :
- What is an acceptable fps count?
- What is an acceptable garbage count, when collecting garbage is needed?
- What would be a reasonable amount of garbage collection? Is that possible to estimate it by ourselves?
@Mells I'm starting to think that I'm going to waste my 2000th comment, because I probably can't be much of a help in this case, but, let me try
If you mean acceptable fps count on which game should run, then it probably depends on device. With lot's of sprites and box2d objects it would be probably good to have 20-30fps on amrv6 phones.
However on middle class phones it would be already expected to have 50-60.
Me, I actually don't feel fps drop down to about 45 when playing, only on 40 fps I start to see, that something seems to be wrong Yeah, I'm not picky
And I really not a fan of manual garbage collecting. In my games I try to use pools where the objects as bullets (which should appear many of them) are not destroyed but are thrown back to pool to be reused again.
So for me, as nothing gets deleted, doing one garbage collect on scene exit is a maximum I could do.
I don't think I could have find it, even after several dozen of minutes of web/forum searches. Well I am trying to follow the same practices but it's not bad to have another security like @tkhnoman is doing at 15 000 :
About that collect garbage number, you can try to set the security loose, and see that a crash might occur at some point. Then you might give limit based on that and the number of your normal memory usage. Mine is around 6000, that is why i limit it around 2 times of it. (And because i simply like multiple of 5. ) )