0 registered members (),
677
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Memory Consumption
#413956
12/20/12 10:11
12/20/12 10:11
|
Joined: Nov 2006
Posts: 59 Alberta, Canada
Dveyee
OP
Junior Member
|
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:
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
|
|
|
Re: Memory Consumption
[Re: Dveyee]
#413961
12/20/12 11:16
12/20/12 11:16
|
Joined: Sep 2007
Posts: 101 Luxembourg
krial057
Member
|
Member
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: Dveyee]
#413992
12/20/12 22:26
12/20/12 22:26
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
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: Dveyee]
#414000
12/21/12 00:34
12/21/12 00:34
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
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
OP
Junior Member
|
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
|
|
|
|