Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, dr_panther, Quad), 935 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Memory Consumption #413956
12/20/12 10:11
12/20/12 10:11
Joined: Nov 2006
Posts: 59
Alberta, Canada
Dveyee Offline OP
Junior Member
Dveyee  Offline OP
Junior Member

Joined: Nov 2006
Posts: 59
Alberta, Canada
Hi, I have a very simple snippet which dynamically creates an entity as the player approaches and also dynamically removes it once the player has moved far enough from it. My problem now is that when I open up the Statistics Panel (F11) it shows an increasing amount of memory being consumed (ie: nex, mem, geo, shd, all increase and free memory decreases) as I move the player forward. Any idea why more memory is being consumed even though theoretically the amount of memory being used is the same? Albeit, the memory consumption rate is very slow.

Here are some important snippets:
Code:
action sector_life(){
	while(1){
		if(vec_dist(player.x,my.x) > 1000){
			ptr_remove(me);
			break;
		}
		wait(1);
	}

void level_init(){
	while(player==NULL)wait(1);
	var x_count = 512; // first sector is 512 units in length
	
	// create an empty entity in front of the player
	ENTITY* limit_ent = ent_create(NULL, vector(player.x+100, player.y, player.z), NULL);
	
	while(1){
		if(vec_dist(player.x,limit_ent.x) < 100){
			ent_create("sector1.wmb",vector(x_count,0,0),sector_life);
			x_count += 512;
			limit_ent.x += 512;
		}
		wait(1);
	}
}


Many Thanks,
David


Accelerated Game Creation Tutorial - Learn how to use 3D Gamestudio's WED with these exciting video tutorials!

Visit our website at http://www.accgames.com.
Re: Memory Consumption [Re: Dveyee] #413961
12/20/12 11:16
12/20/12 11:16
Joined: Sep 2007
Posts: 101
Luxembourg
K
krial057 Offline
Member
krial057  Offline
Member
K

Joined: Sep 2007
Posts: 101
Luxembourg
I didn't look in detail. But you have to finish the while loop in level_init once(or change the if condition)... At the moment, a new entity is created every frame. Maybe you want to put the count_x in the if condition?

Last edited by krial057; 12/20/12 11:27.
Re: Memory Consumption [Re: krial057] #413984
12/20/12 19:47
12/20/12 19:47
Joined: Nov 2006
Posts: 59
Alberta, Canada
Dveyee Offline OP
Junior Member
Dveyee  Offline OP
Junior Member

Joined: Nov 2006
Posts: 59
Alberta, Canada
Yes, a new entity is created once the distance between the invisible entity in front of the player is within 100 quants; however, the new entity is removed once the player has moved over 1000 quants away from it.


Accelerated Game Creation Tutorial - Learn how to use 3D Gamestudio's WED with these exciting video tutorials!

Visit our website at http://www.accgames.com.
Re: Memory Consumption [Re: Dveyee] #413989
12/20/12 22:10
12/20/12 22:10
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
nope
your code creates an entity every frame if the distance to the player is < 100
you don't do any checks how many models you've created


Visit my site: www.masterq32.de
Re: Memory Consumption [Re: MasterQ32] #413990
12/20/12 22:22
12/20/12 22:22
Joined: Nov 2006
Posts: 59
Alberta, Canada
Dveyee Offline OP
Junior Member
Dveyee  Offline OP
Junior Member

Joined: Nov 2006
Posts: 59
Alberta, Canada
I think I see what you mean. Any tips on limiting the number of models created per frame?


Accelerated Game Creation Tutorial - Learn how to use 3D Gamestudio's WED with these exciting video tutorials!

Visit our website at http://www.accgames.com.
Re: Memory Consumption [Re: Dveyee] #413991
12/20/12 22:24
12/20/12 22:24
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
EDIT: DELETE THIS!

Last edited by MasterQ32; 12/20/12 22:24.

Visit my site: www.masterq32.de
Re: Memory Consumption [Re: Dveyee] #413992
12/20/12 22:26
12/20/12 22:26
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Dveyee, you don't need to reduce the number of models create per frame. At most one entity is created per frame.

MasterQ32, have you noticed that limit_ent.x is also increased when an entity is created and this variable is also used in the if comparison. At first I had the same thought like you, but I don't think this will happen here. The code is not elegant, but it should work as Dveyee describes, shouldn't it?

Dveeyee, does the number of entities rapidly increase? You can see it in the debug panel as well. It shouldn't.


Always learn from history, to be sure you make the same mistakes again...
Re: Memory Consumption [Re: Uhrwerk] #413997
12/20/12 23:25
12/20/12 23:25
Joined: Nov 2006
Posts: 59
Alberta, Canada
Dveyee Offline OP
Junior Member
Dveyee  Offline OP
Junior Member

Joined: Nov 2006
Posts: 59
Alberta, Canada
Hi Ukrwerk, no it does not rapidly increase. The initial entity count is 1 and as I move my player forward it increases up to 6 where it stabilizes (ent_create = ent_remove); however, the memory consumption still increases slowly.


Accelerated Game Creation Tutorial - Learn how to use 3D Gamestudio's WED with these exciting video tutorials!

Visit our website at http://www.accgames.com.
Re: Memory Consumption [Re: Dveyee] #414000
12/21/12 00:34
12/21/12 00:34
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
That clearly shows you're not creating too much entities.

Can you please be more specific about "consumption going up"? Which part is exactly going up and by what amount. Could you please provide screenshots when the game is started and when it ran for quite some time?


Always learn from history, to be sure you make the same mistakes again...
Re: Memory Consumption [Re: Uhrwerk] #414002
12/21/12 01:37
12/21/12 01:37
Joined: Nov 2006
Posts: 59
Alberta, Canada
Dveyee Offline OP
Junior Member
Dveyee  Offline OP
Junior Member

Joined: Nov 2006
Posts: 59
Alberta, Canada
Give it a try yourself! Press "W" to move forward.

You'll notice that the F11 Statistics Panel shows an increase in memory being used as the player moves forward.

memory.zip


Accelerated Game Creation Tutorial - Learn how to use 3D Gamestudio's WED with these exciting video tutorials!

Visit our website at http://www.accgames.com.
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1