Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Paused Running Scripts slow down?  (Read 7780 times)

0 Members and 1 Guest are viewing this topic.

Darky

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 109
    • View Profile
    • Spreadcamp
Paused Running Scripts slow down?
« on: September 16, 2011, 12:33:38 AM »

In my game I'm experiencing a issue where it slows down a lot over time. It eventually becomes downright unplayable with extremely low FPS. At later points in the game on some extreme usage cases it takes several minutes to load the save game. My first instinct is that it's a running script issue, but I'm not quiet sure what really is going wrong. I look at the debugger and I don't see a particular script really standing out. Maybe I just don't know how to read it properly?

When I load one of those save games that are heavily affected, I can read:
Running scripts: 881 (r:11 w:1 p:869)

From what I read on a similar topic in the past, paused scripts should not interfere.

I tried to find something that gets loaded over and over, but I could not find such a thing. Am I missing something?

I'm really unsure what I should try to do or what might be the problem. What should I look out for, especially in terms of "suspicious behavior" in the Debugging Console?

Thank you
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Paused Running Scripts slow down?
« Reply #1 on: September 16, 2011, 07:03:25 AM »

I tried to find something that gets loaded over and over, but I could not find such a thing. Am I missing something?
Yes, I think you most definitely are missing something. 869 scripts is hell of a lot, so I do believe you keep loading something (entities, actors, windows) and never release them. The number of scripts is just a secondary symptom, there are some objects owning the scripts, sitting in memory.

Sadly I don't think there's a way to unveil those in the Debugging Console. There is a diagnostic script command that will write the number of internal WME objects to a file:

Code: WME Script
  1. Game.DEBUG_DumpClassRegistry();
  2.  

If you call this, it will generate a file called 'zz_class_reg_dump.log' in the game directory (or project directory when called from ProjectMan). Look for lines with huge numbers; there will be your 869 CScScript line, tons of CScValue, and... something else. That will at least tell you what exactly is hogging the memory, whether those are windows, entities or actors.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Darky

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 109
    • View Profile
    • Spreadcamp
Re: Paused Running Scripts slow down?
« Reply #2 on: September 16, 2011, 02:07:18 PM »

Hey Mnemonic,

I used the command. The file generated is here: http://pastebin.com/raw.php?i=atX1mHQs

I see a high number for CBFrame and CBSubFrame (not sure what that is. Sprites?)

More suspicious are CUIWindow (359) and Entity (651)

If it's entities I'm not sure why they pile up. Aren't they supposed to clear up when you change scene? I don't initialize them in globals.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Paused Running Scripts slow down?
« Reply #3 on: September 16, 2011, 02:31:12 PM »

So, apparently you keep loading some window, containing an entity container, over and over and you never unload it. That should help you narrow the search, right?
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Darky

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 109
    • View Profile
    • Spreadcamp
Re: Paused Running Scripts slow down?
« Reply #4 on: September 16, 2011, 06:09:05 PM »

Thanks, it does narrow it down. I identified several windows that stay in memory. They are not really getting loaded over and over (as far as I can see) but that they stay in Memory is bad enough. I'm getting rid of them right now by using Game.UnloadObject() and I will conduct some playtesting to see if it still appears once I am done with that.

I'll let you know the result.

Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Paused Running Scripts slow down?
« Reply #5 on: September 16, 2011, 06:39:38 PM »

They are not really getting loaded over and over (as far as I can see) but that they stay in Memory is bad enough.
But there are over 300 of them... that would suggest they are being reloaded frequently.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Darky

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 109
    • View Profile
    • Spreadcamp
Re: Paused Running Scripts slow down?
« Reply #6 on: September 16, 2011, 07:03:10 PM »

They are not really getting loaded over and over (as far as I can see) but that they stay in Memory is bad enough.
But there are over 300 of them... that would suggest they are being reloaded frequently.
On the windows I identified there are lots of entities with lots of scripts that react to things like MouseEntry, get called by other entities to do something etc. - Lots of little scripts that execute up to the end of their script. But then when I close the window, I did not Unload it. After that you can go back and use the same Window again, for example for Elevator Controls, and it would pile up another handful of the same scripts, all having executed to their end, and again it wouldn't unload the window. Apparently you could do this without end and clog the memory up.

At least that's how it seems to be. The Debugger showed me several windows that have their windows and scripts still loaded. For example the mentioned elevator would end up with some 20-40 scripts for the same thing, all doing nothing (at end of their lines according to Debugger)

When you said "reloaded" I thought of something more obvious like a window really being re-opened all the time. All I can guess with the way it seems to be, is that it probably goes on executing the paused scripts from the start? Is that it?

But I'll know more later when I made the proper Unloads everywhere.
« Last Edit: September 16, 2011, 07:05:48 PM by Darky »
Logged

Darky

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 109
    • View Profile
    • Spreadcamp
Re: Paused Running Scripts slow down?
« Reply #7 on: September 17, 2011, 01:30:44 AM »

Okay so I hunt down all the windows I could find and did my testing with the new fixes.

Here's the new dump from the same scene as the last one: http://pastebin.com/raw.php?i=JyymXti9

I feel like there's still some FPS loss over the course of the game, but maybe I'm imagining things. What do you say, Mnemonic?

I have a few windows open at all times but they are loaded via game.script and then manipulated by other scripts (change values, make visible/invisible). They shouldn't interfere, though.

Debugger itself is looking clean. No more left overs in there from other scenes and window scripts.
« Last Edit: September 17, 2011, 01:34:40 AM by Darky »
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Paused Running Scripts slow down?
« Reply #8 on: September 17, 2011, 08:29:01 AM »

Yeah, it looks much better.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.039 seconds with 21 queries.