Stencyl 3.4.0 is now out. Get it now!

Non Named (Debugging, maps, and other stuff)

fillergames

  • Posts: 732
Is it normal for the RAM usage to constantly increase when using telemetry? If not, I think I may have found a massive memory leak problem.

Edit: Testing an older version of the game makes the RAM usage juggle from 99.6 MB and 84.4 MB. Going to disable telemetry on the most recent build to see if that's indeed the issue.

Edit 2: This looks pretty bad. Judging by the collection use, it seems to be what happens when you exit from a battle to the overworld. Quite a nasty spike right there.



As you can see from the other bar at the top, the game mostly runs fine until you switch scenes. That seems to be when the garbage collection and event handling go nuts. The example below is the engine running at it's worst.



Most of the time, it otherwise seems to run like this.


« Last Edit: November 06, 2017, 07:52:36 pm by fillergames »

Justin

  • *
  • Posts: 3811
No, telemetry shouldn't cause the ram to keep increasing.

There's clearly something going on every frame in the second screenshot to the left. What takes up the most memory in the allocations tab when you select a range of those frames?

For Live Support: Join our discord channel and ping me @justin.

fillergames

  • Posts: 732
Seems to be strings, and Box 2D related allocations. (The Box 2D stuff all uses 0 KB, but has high counts)



I think it may be an extension? No idea.

fillergames

  • Posts: 732
Well, I can confirm that telemetry was indeed causing the RAM to increase memory-leak style. I did disable some extensions I don't use, which I have no idea if it helped.

As now, the game runs always under 145 MB in the larger areas, and about 100 MB in the menus.

What seems to be the culprit for the RAM spike seems to be exiting from a battle, or entering one.  I assume it's the use of shaders on every frame when the battle swipe happens?

Edit: Here's a slowed down gif of the swipe itself. Dunno why the colours went bonkers when I was done recording it, but eh. If you can see it right, it has the blur shader on every frame. And I assume that the shader being on every frame may be the cause of the frame-by-frame ladder effect on the memory usage.


« Last Edit: November 06, 2017, 08:29:19 pm by fillergames »

fillergames

  • Posts: 732
Left my game for about 40-50 minutes on idle to see if anything changed. Here's the memory usage



Top was when I booted it up, and the bottom was afterwards. Moving seemed to cause the usage to jump a bit, so I think there's something going on with the movement scripts.

Bombini

  • Posts: 830
Let me test an exe if you want!
I can also take a look at your movement script.

Cheers!

fillergames

  • Posts: 732
A more subtle form of optimization, but I think it works.



So I decided that for some scripts that aren't used for actions that are fluid (such as this, which is what sets character icons on the menu hud to be greyed out or not) don't need an updated block.

My reasons for this is to reduce the amount of cycles the script uses. Why use 60 (or 100, which is what I think updated runs it's cycles/second at) when you can do 30? While some people will get angry that this means this action isn't true 60 FPS. But why does it matter when it's for something so minor such as what sets character icons to be grey?

Also, less verbose checking in an if script helps. Not need for checking if a bool is equal or false, just bool, or not bool.

And yes, these are how I name my game attributes. Helps makes things not boring when doing code.

fillergames

  • Posts: 732


After a massive organization of atlas use, the memory use on menus has shrunken down massively. (A whopping 34.4% decrease!)

This is the same menu scene before I optimized things:



Edit: Another map, this one is real rough so far. And I may switch the tilesets to prevent monotonous design for the upper area of this map.


« Last Edit: November 11, 2017, 06:15:28 pm by fillergames »

fillergames

  • Posts: 732
Been looking at what causes the laggy behavior on the items menu on Flash, and I can confirm it's the front drawing.

I may have to optimize it or something. Which I think may be possible.

fillergames

  • Posts: 732
Behold on what may be the worst code I've done on a menu drawing script. And also lo and behold how much I optimized it!

https://i.imgur.com/0P2D1KY.png (Image is way too large to be shown in the forums on a mobile device or something, so I just made it a URL)

Using 2 variables, and a simple use of the "get current loop count" block. I've cut it down massively. Which I'm, pretty sure will help make the items menu less laggy on Flash and such. This took about five minutes to optimize. I find it actually quite odd I didn't do it this way the start, as it requires less manual labor, and is easier on resources.



Edit: This did fix it. So that's one issue down the drain.

« Last Edit: November 15, 2017, 02:57:38 pm by fillergames »