Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: hubertMichael on June 07, 2012, 09:53:42 PM

Title: Memory Problem
Post by: hubertMichael on June 07, 2012, 09:53:42 PM
Hi

I got very strange problem. I got 2d adventure game.

Size of my main actor all frames is 53 MB.
wme.exe process memory size is 97 MB without actor but when I load actor by "jack = Game.LoadActor("actors\jack\jack.actor");" wme.exe process growing to 900 MB !!! What is going on?? Because of this I can't load second actor.
Title: Re: Memory Problem
Post by: metamorphium on June 07, 2012, 10:35:01 PM
I bet you have a recursion and loading your actor over and over and over. :)

Please post the whole relevant script. (is it in base.inc? :))
Title: Re: Memory Problem
Post by: hubertMichael on June 07, 2012, 11:06:16 PM
No, it's not in any loop

This is my script for button "new game":

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


////////////////////////////////////////////////////////////////////////////////
on "MouseEntry"
{
load_game_h.Active = false;
new_game_h.Active = true;
}

on "LeftClick"
{
//Game.ChangeScene("scenes\intro\intro.scene");
Game.ChangeScene("scenes\loading_screen\loading_screen.scene");
}

So it changes scene to loading_screen.

This is scene_init for loading_screen.scene

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



// load our main actor
Sleep(1500);
jack = Game.LoadActor("actors\jack\jack.actor");
//cyber_jack = Game.LoadActor("actors\cyber_jack\cyber_jack.actor");
//cyber_jack.Active = false;
actor = jack;
Game.MainObject = actor;
Game.InventoryObject = actor;


jack.TakeItem("cyber_deck");
//cyber_jack.TakeItem("cyber_deck2");

bar = Game.LoadWindow("interface\character_bar\char.window");
indyk = bar.GetWidget("indyk");

Game.ChangeScene("scenes\jacks_ship\jacks_ship.scene");


In jacks_ship scene_init there is no any LoadActor command. I'm loading actor only in scene_init of loading_screen.

There is also no LoadActor in base.inc

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

global Scene;
global Keyboard;
global actor;
global jack;
global cyber_jack;
global real_room;
global x,y,actor_facing, attx;
global jack_from;

//loading_screen
global twirl;


//title screen
global new_game_h, new_game, load_game, load_game_h;

//jack's ship
global ship_lights, blackout, offPanel, offPanel_state, floor_hole, engine_wires;
global door_opened, door_closed, outer_light, ship_out;
//door panel
global cable_sp, switch_led_sp, l1, l2, l3, l4, l5, l6;
global sw1, sw2, sw3, sw4, sw5, sw1_0, sw2_0, sw3_0, sw4_0, sw5_0;
global led1, led2, led3, led4, led5, led6;
global switch1, switch2, switch3, switch4, switch5, cable_state, open_ship;

//outside ship


global intro;
global bar;
global indyk;

function indicator(xp)
{
  attx = (308 / 100) * xp + 308;
  indyk.SkipTo(attx,27);
}

Title: Re:Memory Problem
Post by: metamorphium on June 07, 2012, 11:10:45 PM
can you also post actor's definition and script?
Title: Re: Memory Problem
Post by: hubertMichael on June 07, 2012, 11:22:09 PM
this is jack.actor

Code: [Select]
; $EDITOR_PROJECT_ROOT_DIR$ ..\..\..\

ACTOR
{
  NAME = "jack"
  CAPTION=""
  SCALABLE = TRUE
  INTERACTIVE = FALSE
  X = 400
  Y = 460
  SCRIPT="actors\jack\jack.script"

  FONT = "fonts\Sansation_Regular.font"

  ANIMATION
  {
    NAME       = "idle"
   
    LEFT       = "actors\jack\ll\idle.sprite"
    RIGHT      = "actors\jack\rr\idle.sprite"
    UP         = "actors\jack\uu\idle.sprite"
    DOWN       = "actors\jack\dd\idle.sprite"

    UP_LEFT    = "actors\jack\ul\idle.sprite"
    UP_RIGHT   = "actors\jack\ur\idle.sprite"
    DOWN_LEFT  = "actors\jack\dl\idle.sprite"
    DOWN_RIGHT = "actors\jack\dr\idle.sprite"
  } 
 
  ANIMATION
  {
    NAME       = "walk"
   
    LEFT       = "actors\jack\ll\walk.sprite"
    RIGHT      = "actors\jack\rr\walk.sprite"
    UP         = "actors\jack\uu\walk.sprite"
    DOWN       = "actors\jack\dd\walk.sprite"

    UP_LEFT    = "actors\jack\ul\walk.sprite"
    UP_RIGHT   = "actors\jack\ur\walk.sprite"
    DOWN_LEFT  = "actors\jack\dl\walk.sprite"
    DOWN_RIGHT = "actors\jack\dr\walk.sprite"
  }

  ANIMATION
  {
    NAME       = "talk"
   
    LEFT       = "actors\jack\ll\talk.sprite"
    RIGHT      = "actors\jack\rr\talk.sprite"
    UP         = "actors\jack\uu\talk.sprite"
    DOWN       = "actors\jack\dd\talk.sprite"

    UP_LEFT    = "actors\jack\ul\talk.sprite"
    UP_RIGHT   = "actors\jack\ur\talk.sprite"
    DOWN_LEFT  = "actors\jack\dl\talk.sprite"
    DOWN_RIGHT = "actors\jack\dr\talk.sprite"
  }
 
  ANIMATION
  {
    NAME       = "talk_special"
   
    LEFT       = "actors\jack\ll\wakeUp2.sprite"
  }

  ANIMATION
  {
    NAME       = "turnleft"
   
    LEFT       = "actors\jack\ll\turn.sprite"
    RIGHT      = "actors\jack\rr\turn.sprite"
    UP         = "actors\jack\uu\turn.sprite"
    DOWN       = "actors\jack\dd\turn.sprite"

    UP_LEFT    = "actors\jack\ul\turn.sprite"
    UP_RIGHT   = "actors\jack\ur\turn.sprite"
    DOWN_LEFT  = "actors\jack\dl\turn.sprite"
    DOWN_RIGHT = "actors\jack\dr\turn.sprite"
  }
 
  ANIMATION
  {
    NAME       = "turnright"
   
    LEFT       = "actors\jack\ll\turn.sprite"
    RIGHT      = "actors\jack\rr\turn.sprite"
    UP         = "actors\jack\uu\turn.sprite"
    DOWN       = "actors\jack\dd\turn.sprite"

    UP_LEFT    = "actors\jack\ul\turn.sprite"
    UP_RIGHT   = "actors\jack\ur\turn.sprite"
    DOWN_LEFT  = "actors\jack\dl\turn.sprite"
    DOWN_RIGHT = "actors\jack\dr\turn.sprite"
  } 
}

and scirpt is empty

Code: [Select]
#include "scripts\base.inc"
Title: Re:Memory Problem
Post by: metamorphium on June 07, 2012, 11:27:00 PM
If you copy Molly (default actor from WME demo) to your project and load her instead, do you still get the same behavior?
Title: Re: Memory Problem
Post by: hubertMichael on June 07, 2012, 11:33:19 PM
with molly everything is ok. So what's wrong with my actor?
Title: Re: Memory Problem
Post by: hubertMichael on June 07, 2012, 11:54:20 PM
I just noticed that when I'm walking with my actor, wme.exe memory size is growing. When my actor doesn't move memory size of wme.exe is the same (not droping, not growing) when I move my actor it is growing again :( Please help my, I'm fighting with the problem all day. I didn't see this strange behaviour earlier.
Title: Re: Memory Problem
Post by: hubertMichael on June 08, 2012, 03:02:48 AM
frames of my actor are in indexed png but I have tried jpg, bmp with the same result. It looks like my actor generating some kind of memory leak... I don't know.

I'm depressed
Title: Re: Memory Problem
Post by: Mnemonic on June 08, 2012, 06:45:54 AM
The important thing is the size of the PNG frames (width/height). Then you can do a simple math: each image will take width * height * 4 bytes of memory (possibly more if the image dimensions are not power of two and the video card requires it).
If your images contain lots of empty space, remove it.
Title: Re: Memory Problem
Post by: metamorphium on June 08, 2012, 09:09:17 AM
Oh! the size of main actor's png files is 53MB - not the actual size? Then it can easily lead to 900MB memory usage.

Title: Re: Memory Problem
Post by: Spellbreaker on June 08, 2012, 09:46:14 AM
Just a guess ( we did the same with an animation wondering about the memory usage ): Me made a litte animation, but simply forgot to crop it, so the animation was ... dunno... 100x100 px or so, but the frames all were 1280x720. Doesn't matter if transparent or not, memory usage is the same ;) ;)

Other thing is maybe you simply have too much frames? We have good results using 10 FPS for Characters (for our comic-style), it looks really good.

Our WME Process is always ~250 MB - ~300 MB with all needed stuff loaded.

Greets,

Spellbreaker
Title: Re: Memory Problem
Post by: metamorphium on June 08, 2012, 09:56:30 AM
Also it's healthy to split certain stuff into several actors to reduce frames and load them on demand. Not all animations needed to be in one file and always loaded in the memory.
Title: Re: Memory Problem
Post by: hubertMichael on June 08, 2012, 02:46:08 PM
there is no difference if my frames are power of two or not. I have cropped frames and it didn't helped. After I cropped my process of wme.exe wasn't 900 MB but 300 Mb and it was growing again. Five minutes of playing and it was almost 400 MB and still growing. Thank you guys for your tips but still I got my problem. There is some leak and I don't know where.
Title: Re: Memory Problem
Post by: Mnemonic on June 08, 2012, 02:51:06 PM
So... will you tell us how big are the images and how many are there?
Title: Re: Memory Problem
Post by: hubertMichael on June 08, 2012, 02:59:58 PM
160 x 460 pixels. I got walk (30 frames - I have tried with less number of frames but it wasn't look natural), talk (5 frames), Idle (30 frames cause I need slow smooth motion).

I have just discovered something. I don't know if this is bug of wintermute or just me. When I turned on all idle animation to streaming animation - memory leak just stopped. What happend?
Title: Re: Memory Problem
Post by: Spellbreaker on June 08, 2012, 03:14:47 PM
I don't know, I think the problem is somewhere else, script related. We preload around ~600 Frames of Animation just for the Mainactor, and the WME process is constantly around 250 MB ( depending of the Scene we are in.) Your animations aren't too big imo.
Title: Re: Memory Problem
Post by: metamorphium on June 08, 2012, 07:42:06 PM
Ok, I have a feeling something doesn't fit in here:

65 frames 160x460 uncompressed equals to less than 20MB. Png uses compression and you told us that it's 53 MB. I am not sure what to think of this all. :)

1. Did you try using molly instead of your character?
2. Do you use any specific script for idle animation?

Title: Re: Memory Problem
Post by: hubertMichael on June 08, 2012, 08:01:50 PM
metamorphium: Sorry, 53 MB was before I have cropped frames
Title: Re: Memory Problem
Post by: hubertMichael on June 08, 2012, 08:04:41 PM
It's ok for now. I have cropped frames and Idle and talk animation turned to streaming animation. So memory leak stopped and my proscess of wme.exe is ~180 MB.