Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Pages: 1 2 3 [All]

Author Topic: unload scene  (Read 15720 times)

0 Members and 1 Guest are viewing this topic.

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
unload scene
« on: May 28, 2013, 10:06:04 PM »

Hi

How can I completly unload scene from memory? I'm asking because every time when I'm changing scene to another by (Game.ChangeScene) I got feeling that my game starts to take more and more memory. I've checked every script, actors, everything and I don't know what's going on. The only possibility which comes to my mind is that WME does not release the memory completely from previous scene and something is collecting. That would explain why game starts to take more and more memory. Therefore I want to completly unload current scene from memory before I will use Game.ChangeScene. How can I do this?
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: unload scene
« Reply #1 on: May 29, 2013, 06:55:33 AM »

WME does unload the old scene. You'd run out of memory pretty fast if it didn't.
If you feel some stuff is staying it memory, the tips from your other thread still apply (namely the DumpTextureStats() method).
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: unload scene
« Reply #2 on: May 29, 2013, 09:08:08 AM »

I did DumpTextureStats() method and I didn't find anything suspicious. Maybe I didn't notice something. I'll do it once again today just for double check and I'll share with results here.
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

2.0

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 217
    • View Profile
Re: unload scene
« Reply #3 on: May 29, 2013, 01:13:13 PM »

In general, it is easy to check whether the memory leaks exactly in WME or not - you need to run one of the many games based on the WME to check its behavior. I think if the problem in memory leak in the engine existed, it would have been a well known (at worst).
The issue, I think, still in the scripts. But without seeing the sources, is hard to figure out what was wrong.
Logged

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: unload scene
« Reply #4 on: May 29, 2013, 11:07:25 PM »

Ok, I did few tests and I got really strange results.

- I did empty scene only with my actors. But there is no any other graphics. I got access to this scene using TAB key and in scene init there is dumptextures method. WME process takes 383 MB and this is normal because I got 3 actors with lots of frames. Dump textures file didn't show any anomalies
- after 5 min of palying I got to my test scene. WME process takes 512 MB (there is lot of animations)
- I did save game for this moment and hit TAB key to jump to my empty scene
- WME process dropped to 480 MB (should be ~ 383 MB like I said in the begining) Dump textures file didn't show any anomalies
- I turned off my game and turn on again
- I've loaded my save game. WME process takes now 464 MB (not 512 MB as in the moment when I was saving)
- I hit TAB key to jump to my empty scene and now WME process takes ~383 as in the begining

Soo... there is something wrong. Where should I look? It's not textures because now I'm sure but something strange is happening

Here is one of my actors script. Maybe I'm doing something wrong here. It's about footstep sound.

Code: [Select]
#include "scripts\base.inc"

on "footstep"
{
var rsteps;
var Reg = Scene.GetRegionAt(this.X, this.Y);

var steps;

if(Reg.fNature == "metal")
{
steps[0] = "sounds\fx_footsteps\metal\footstepMetal1.ogg";
steps[1] = "sounds\fx_footsteps\metal\footstepMetal2.ogg";
steps[2] = "sounds\fx_footsteps\metal\footstepMetal3.ogg";
steps[3] = "sounds\fx_footsteps\metal\footstepMetal4.ogg";
steps[4] = "sounds\fx_footsteps\metal\footstepMetal5.ogg";
steps[5] = "sounds\fx_footsteps\metal\footstepMetal6.ogg";
steps[6] = "sounds\fx_footsteps\metal\footstepMetal7.ogg";
rsteps = Random(0, 6);
}
if(Reg.fNature == "concrete")
{
steps[0] = "sounds\fx_footsteps\concrete\concrete1.ogg";
steps[1] = "sounds\fx_footsteps\concrete\concrete2.ogg";
steps[2] = "sounds\fx_footsteps\concrete\concrete3.ogg";
steps[3] = "sounds\fx_footsteps\concrete\concrete4.ogg";
steps[4] = "sounds\fx_footsteps\concrete\concrete5.ogg";
rsteps = Random(0, 4);
}
if(Reg.fNature == "concrete_inside")
{
steps[0] = "sounds\fx_footsteps\concrete_indoor\concrete_indoor1.wav";
steps[1] = "sounds\fx_footsteps\concrete_indoor\concrete_indoor2.wav";
steps[2] = "sounds\fx_footsteps\concrete_indoor\concrete_indoor3.wav";
steps[3] = "sounds\fx_footsteps\concrete_indoor\concrete_indoor4.wav";
steps[4] = "sounds\fx_footsteps\concrete_indoor\concrete_indoor5.wav";
rsteps = Random(0, 4);
}



this.PlaySound(steps[rsteps]);
}

I've turned off my actors footsteps and problem still exist. Any tips would be very helpful

It's look like something is collecting in memory during gameplay but it disappear after game load. It's not textures, it's not actors footsteps (because I'v turned this off). So this must be some garbage data in memory which is not included to save game file.
« Last Edit: May 30, 2013, 01:31:12 AM by hubertMichael »
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

donamin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 27
    • View Profile
Re: unload scene
« Reply #5 on: May 30, 2013, 02:52:00 PM »

i'm having this problem too.
it seems that scenes are not unloaded completely.
i'm trying to implement a pause menu. i implemented my menu using a new scene. i use changescene to pause menu when esc is pressed. every things works fine, but when i press "new game" button in pause menu which loads that scene  using changescene again, some elements of scene are missing!
Logged

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: unload scene
« Reply #6 on: May 30, 2013, 03:39:24 PM »

donamin: I think that in your case it's completly different problem. From what you're saying you did something wrong with some variables. Maybe they need to be reseted to it's default values or something like this. I'm sorry but I suggest you to make a new topic about your problem and show us your scripts. I'm sure by then we will be able to help you.

Alright, I did another test on different scenes. Problem still exist. Dump texture method didn't help me. In csv file everything is alright. So...
I got three scenes:
A - there nothing but my two actors. There is any entity.
B - there is only my main actor. There is any entity.
C - there is only my actor and really really big spirtes. There is any entity.

Im going in circle through this scenes in this order A -> B -> C ->  A -> B -> C -> A -> B -> C -> A -> B -> C
WME process takes memory like this:
1   A = 380 MB
2   B = 450 MB
3   C = 594 MB
4   A = 390 MB
5   B = 429 MB
6   C = 640 MB
7   A = 440 MB
8   B = 482 MB
9   C = 675 MB
10 A = 505 MB
11 B = 530 MB
12 C = 715 MB

I did absolutely nothing in these scenes. I was just walking. It looks like a memory leak for me because right now I don't have any idea what's wrong. Dump texture is alright. In base.inc I don't have any stuff like Game.LoadWindow or similar user failures. What I was telling in the posts above, after game load memory is going back to normal usage. So... what else?
« Last Edit: May 30, 2013, 03:41:11 PM by hubertMichael »
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: unload scene
« Reply #7 on: May 30, 2013, 03:57:40 PM »

When you're performing these tests, is the debug console on, by any chance?
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: unload scene
« Reply #8 on: May 30, 2013, 04:05:28 PM »

Yes, I got always debug console on.

I've checked sprites if keep loaded in memory is turn off. It is turned off. Now before Game.Changescene I've used Scene.UnloadObject for all sprites in scene. No results, problem still exist.
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: unload scene
« Reply #9 on: May 30, 2013, 04:10:09 PM »

The debug console is using Microsoft .NET framework, which uses garbage collector. That means it keeps the memory allocated (as long as there's enough memory available) and only releases it from time to time or when more memory is needed. That would explain your memory usage fluctuations.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: unload scene
« Reply #10 on: May 30, 2013, 04:13:47 PM »

So if I will disable debug console everything should back to normal? I'll check it right now.
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: unload scene
« Reply #11 on: May 30, 2013, 04:20:51 PM »

I've disabled debug console and unfortunately problem still exist. Ofcourse WME process takes less memory but it's usage is still growing. Not so fast as with debug console but it's growing slowly.
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: unload scene
« Reply #12 on: May 30, 2013, 04:35:03 PM »

How slowly? Some growth is expected, because if the "remember node state" option is enabled in scenes, the node states are stored in memory permanently.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: unload scene
« Reply #13 on: May 30, 2013, 05:07:17 PM »

It's not slowly. It's just a smaller numbers. I've turned off remember nodes states and including sprites in my test scenes A, B, C. I was walking through them like before A -> B -> C -> A ...

1  A = 353 MB
2  B = 407 MB
3  C = 580 MB
4  A = 367 MB
5  B = 412 MB
6  C = 628 MB
7  A = 419 MB
8  B = 466 MB
9  C = 662 MB
10 A = 450 MB
11 B = 506 MB
12 C = 696 MB

Debug conlsole is set to "never",  debug mode is set to "no", show FPS is set to "no". My game is 2D, use direct3d 9 is set to "no".
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: unload scene
« Reply #14 on: May 30, 2013, 05:50:32 PM »

No idea then. If you want to dig really deep, there's this diagnostic command: Game.DEBUG_DumpClassRegistry(); It will create a file called "zz_class_reg_dump.log" in the game directory. It contains a list of all internal objects WME is currently allocating. You can try calling this before and after and compare the two logs to see which of the values are growing significantly.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: unload scene
« Reply #15 on: May 30, 2013, 05:54:02 PM »

I don't want to dig that deep but I must. Thanks for this command. I'll try. If I will find something I'll write here.
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: unload scene
« Reply #16 on: May 30, 2013, 06:37:33 PM »

I did this DEBUG_DumpClassRegistry() test. Like always I was walking through my test scenes A, B, C

First time in scene A I did DEBUG_DumpClassRegistry(), memory usage was very similar to my last time when I was writing above.
Then I did my walk cycle B C A B C A B C A B C A
And then when I was fifth time in scene A I did again DEBUG_DumpClassRegistry()

Using program WinMerge I found this differences:

003   CAdSentence          instances: 0    VS    003   CAdSentence          instances: 1
021   CAdPathPoint         instances: 6     VS    021   CAdPathPoint         instances: 0
038   CScValue             instances: 4823  VS    038   CScValue             instances: 4843
041   CScStack             instances: 264   VS    041   CScStack             instances: 268
042   CScScript            instances: 66      VS    042   CScScript            instances: 67
043   CBSprite             instances: 386     VS    043   CBSprite             instances: 387
066   CBSubFrame           instances: 4183  VS  066   CBSubFrame           instances: 4204
069   CBFrame              instances: 4166   VS   069   CBFrame              instances: 4187

Soo... Mnemonic what all that means because I'm not quite sure what this is telling me.
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: unload scene
« Reply #17 on: May 30, 2013, 06:41:55 PM »

This seems pretty normal to me. One more script running, one more sprite, 20 more sprite frames in total.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: unload scene
« Reply #18 on: May 30, 2013, 07:56:34 PM »

Ok. If I'll find something I will write here.
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

2.0

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 217
    • View Profile
Re: unload scene
« Reply #19 on: May 31, 2013, 12:24:19 AM »

1 more sprites (21 frames and subframes) and ~100-120 Mb more memory. It is ~5-6 Mb per sprite frame. That is approximately corresponds to size of sprite 1600*900 (5.6 Mb).
It can be some kind of animation? Maybe it is some of background animation? Or uncropped actor's animation?
« Last Edit: May 31, 2013, 12:28:32 AM by 2.0 »
Logged

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: unload scene
« Reply #20 on: May 31, 2013, 01:10:28 AM »

2.0: I was thinking about this. But dumptexture should tell me if there is something but it didn't.
« Last Edit: May 31, 2013, 01:14:33 AM by hubertMichael »
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

2.0

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 217
    • View Profile
Re: unload scene
« Reply #21 on: May 31, 2013, 01:50:13 AM »

Is you tried to find this animation ("manually") and disable it? I think this is the only method to get a result in this case.
Logged

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: unload scene
« Reply #22 on: May 31, 2013, 02:22:06 AM »

I'll try to disable spirte by sprite to find it but that is very strange. Why would spirte from previous scene could be a problem? If I'm using changescene then all sprites should be unloaded. I did more, before I'm changing scene I'm unloading sprites manually by Scene.UnloadObject.... I don't even know if it's sprite... DEBUG_DumpClassRegistry indicates, like you noticed, that this is sprite but I don't know... I'll check it.
« Last Edit: May 31, 2013, 02:25:20 AM by hubertMichael »
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: unload scene
« Reply #23 on: May 31, 2013, 07:00:34 AM »

Do you actually have ANY 1600*900 animations?
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: unload scene
« Reply #24 on: May 31, 2013, 01:47:23 PM »

I got that big sprite. It's a complicated rendered atmosphere effect not possible to make with particle system. I've turned this off but why is that a problem? I'm even unloading this sprite from scene before changing scene. Maybe I don't understand how it works but if I'm unloading this then memory should be released and for sure memory usage shouldn't be growing. Thanks for your patience Mnemonic :)
« Last Edit: May 31, 2013, 01:50:59 PM by hubertMichael »
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

2.0

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 217
    • View Profile
Re: unload scene
« Reply #25 on: May 31, 2013, 01:59:30 PM »

Simply interestingly - is this sprite have "Keep in memory" paramether choosen? And how you load and unload this sprite?
« Last Edit: May 31, 2013, 02:02:27 PM by 2.0 »
Logged

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: unload scene
« Reply #26 on: May 31, 2013, 02:02:19 PM »

no. That was the one of the first things to check.
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

2.0

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 217
    • View Profile
Re: unload scene
« Reply #27 on: May 31, 2013, 02:10:50 PM »

Can it be so that you create entity and set sprite to it, and then delete entity? But the loaded sprite it remains in memory? I don't know, whether it is possible, but can quite be.
But if it so, try to create the .entity file and add path to sprite there, then load this file.
Logged

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: unload scene
« Reply #28 on: May 31, 2013, 04:05:38 PM »

Quote
Can it be so that you create entity and set sprite to it, and then delete entity? But the loaded sprite it remains in memory?.

The answear is no. I didn't do it in this way.

But I will try to do it like you said:
Quote
try to create the .entity file and add path to sprite there, then load this file.

and then I'll give my report here
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: unload scene
« Reply #29 on: May 31, 2013, 08:41:55 PM »

I don't know what to add here, so I'll just recap the facts:

1) entities and actors loaded with Scene.LoadEntity() or Scene.LoadActor() will be destroyed automatically when the game changes to another scene
2) so will all entities defined in SceneEdit
3) entities and actors loaded with Game.LoadEntity() or Game.LoadActor() and windows will never be automatically destroyed and you are responsible for unloading them when you no longer need them. They are only destroyed when the game shuts down or when the player loads a saved game.
4) one image can be referenced by multiple sprites. the image is loaded only once and will be released from memory once no sprite references it anymore
5) the memory usage you see in windows task manager includes memory allocated by DirectX, and I have no idea what dirty trick it uses when managing textures
6) sprite frames 1600x900 pixels big are a total overkill and you should find a better solution. video memory is a scarce resource (not as much as it used to, but still) and should be treated as such
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

hubertMichael

  • Regular poster
  • ***
  • Karma: 3
  • Offline Offline
  • Posts: 155
    • View Profile
    • Shadow Of Nebula - our point'n click adventure game
Re: unload scene
« Reply #30 on: May 31, 2013, 10:32:43 PM »

Thanks for advices. It looks that I must redesign few scenes to get rid of such a big sprites because this is the only way I think. I can't still fight with this problem, I need to move forward :) Once again thanks for your patience guys :)
Logged
Shadow Of Nebula fan page:

https://www.facebook.com/shadowofnebula

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: unload scene
« Reply #31 on: June 01, 2013, 12:33:29 AM »

Can you post contents of your base.inc and scene_init.script files?
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet
Pages: 1 2 3 [All]
 

Page created in 0.059 seconds with 23 queries.