Jump to content

Performance problem with sortByDepth


sllarck
 Share

Recommended Posts

I have a performance problem in my game, at the start of game it's all good but when i play for couple of minutes the game starts getting lags and getting slow and slower... I checked out the google chrome profiling And found this: at the start of game sortByDepth is using around 5% but then it starts getting higher and higher after couple of minutes it even reaches 60-70%! I removed all the setDepth() from my code but nothing really changed.

So I kinda know which part of code is causing this problem (pretty big part) but i can't understand why this happens so i can't find a solution. what could be the problem with sortByDepth ??

1587265441_8-18-20182-52-36PM.thumb.jpg.de69ba479f5b452f55140c4d916baab0.jpg

Link to comment
Share on other sites

4 hours ago, Antriel said:

That sounds like a memory leak of some kind. I assume you are removing a lot of game objects and adding new ones. Can you check if `this.children.list.length` keeps increasing or not? If yes, how are you destroying children? Try to make a small reproducible demo if possible.

You are right, I had a graphic object and I needed to change it's width all the time so this is what I was doing: I added the graphic object in create() and  as stupid as it sounds instead of just changing it's width, I was doing clear()  fillRect() in update :)) 
I was just looking for the problem in a wrong place.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...