Memory usage question.

Get help using Construct 2

Post » Sun Sep 04, 2016 7:20 am

I read the memory usage part in the manual and I think I get it, but still ain't sure of what the answer is in the following scenario.

If I have objects that have a var attached to them, for every instance,...is seen (which by default is 0 but becomes 1 when the player's FoV sees it), for example, and they are not Globally persistent or anything, when I leave the layout they get destroyed right. When I come back they are loaded anew with the modified Is Seen var. (if I've seen them or not). My question is, is this bad memory usage? Like, real bad. Where does this modification of the var live? Is it truly unloaded when leaving the layout and the loaded back again when returning?

Cheers!
B
18
S
3
Posts: 65
Reputation: 994

Post » Sun Sep 04, 2016 9:04 am

"My question is, is this bad memory usage? Like, real bad. Where does this modification of the var live? Is it truly unloaded when leaving the layout and the loaded back again when returning?"

No it's not bad memory usage, it's normal. When you leave a layout all instances are forgotten, and when you start a layout all instances will appear as they would on the start of the layout. Again, this is normal.
The LEVEL GENERATOR TOOLKIT



24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 242
Reputation: 2,306

Post » Sun Sep 04, 2016 9:40 am

Perfectly normal. That's why it's called RANDOM access Memory.
B
56
S
15
G
13
Posts: 826
Reputation: 17,645

Post » Sun Sep 04, 2016 2:50 pm

Hey, thanks. That's what I thought, but still I don't get one thing. My example is that a layout loads with one default value of of a variable which a lot of objects have - I then change that value by seeing it with my FOV (read I explore a map which is hidden in uncharted territory by default), I then change the layout, load a new one, and then I return to the former and I still see all the parts of the map which I have seen in my previous exploration (every object I see changes its IsSeen instance variable frmo 0 to 1, and then, on layout start all that are seen are set to visible, all that are not are set to invisible)...this means that the vars i;ve altered during the course of my game are remembered somewhere despite changing layouts. Where is this somewhere? Is it a temp file someplace, it remains in the memory?
B
18
S
3
Posts: 65
Reputation: 994

Post » Sun Sep 04, 2016 3:04 pm

Global variables are ... well .. global.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Sep 04, 2016 3:45 pm

Tis why im talking about instance variables, not global...the sprites have variables, they have a default value, which was then altered and remained altered after leaving the room and coming back. The sprites are made to persist globally (aka not be terminated when the layout is changed.)
B
18
S
3
Posts: 65
Reputation: 994

Post » Sun Sep 04, 2016 9:03 pm

You can make a sprite global, you can give a sprite the Persist behavior.
You can also make a layer global.

Global sprites (and theire instance variables) or sprites on a global layer stay in memory when swapping layouts.
Not sure how the Persist behavior actual works, memory wise. I guess that they stay in memory.

All 3 are really nice features. Got to look em up in the manual, when you plan to change layouts, or take objects from one layout to another (like HUDS).

Memory used by the variables is negligible though, compared to the memory use by the graphics. So, if you have to worry, worry about the amount of sprites (and theire animations) used (independed from if they are global are not). Althaugh, you can have a lot of sprites on screen, as long as you dont try to give them all a personal movement system.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Sep 04, 2016 9:50 pm

Cool cool, thanks!
B
18
S
3
Posts: 65
Reputation: 994


Return to How do I....?

Who is online

Users browsing this forum: Lancifer, Sup with that? and 65 guests