Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (VoroneTZ, 7th_zorro), 1,071 guests, and 5 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
Memory Leak #386905
11/10/11 19:59
11/10/11 19:59
Joined: Oct 2011
Posts: 7
H
hanselkoh Offline OP
Newbie
hanselkoh  Offline OP
Newbie
H

Joined: Oct 2011
Posts: 7
Hi Folks,

I kept have memory leaks despite having ptr_remove().

I am not sure if I am checking the right way, but what I did was I ran the game while looking at the resources used in task manger and it just kept increasing.

here is the short code I wrote.

while(1)
{
ENTITY* enemy = ent_create("unitGolem.wmb", vector(startX,laneY[5],0), putGolem);

ptr_remove(enemy);
wait(10);
}

Any clue on what I did wrongly? Thanks for looking.

Re: Memory Leak [Re: hanselkoh] #386909
11/10/11 20:52
11/10/11 20:52
Joined: Dec 2002
Posts: 616
Austria
Stromausfall Offline
User
Stromausfall  Offline
User

Joined: Dec 2002
Posts: 616
Austria
i used the following code and couldn't reproduce the problem :

Code:
void putGolem()
{
	while(1)
	{
		wait(1);
	}
}

int main()
{
	level_load(NULL);
	wait(1);
	
	while(1)
	{
		ENTITY* enemy = ent_create(CUBE_MDL, vector(1,2,3), putGolem);
	
		ptr_remove(enemy);
		wait(1);
	}
}



I guess the memory leak is most likely hidden somewhere else ...


get the C# wrapper:
for A7.85.4 and A8.30.4, Version 2.3.9
at http://acknexwrapper2.matthias-auer.net/ or visit the thread
Re: Memory Leak [Re: Stromausfall] #386919
11/11/11 03:22
11/11/11 03:22
Joined: Oct 2011
Posts: 7
H
hanselkoh Offline OP
Newbie
hanselkoh  Offline OP
Newbie
H

Joined: Oct 2011
Posts: 7
Thanks Stromausfall, I tried again with a .mdl file instead of .wmb, it seems to be more controlled. But I am still unsure if it's still leaking. How or what is the right way to check for memory leaks?

Re: Memory Leak [Re: hanselkoh] #386922
11/11/11 06:40
11/11/11 06:40
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Entities are a known memory leak, IN CERTAIN CONDITIONS.
I have spent MUCH time discussing it with JCL, for years now...

BTW, 'memory leak' is not the correct term to use.
In normal usage the term 'memory leak' means memory that has 'escaped' the applications control.
In THIS case, acknex still has control over the memory, just your script no longer has...
But for the sake of simplicity, we will keep calling it a 'leak' for now...


Your leak may be coming from several sources. If you test with the example code
that Stromausfall posted above, it will take a LONG time to get any noticable memory loss.
Explaination of the 'certain conditions' can be found in point #1 and #3 below.
So read on...

1> You really should be using ENT_REMOVE to remove entities, not ptr_remove.
I've found ptr_remove can be a bit sloppy on memory cleanups with entities.

2> Any memory that gets 'lost' in this process is 'hiding' in the nexus area.
This can be retrieved/recycled by using level_load or level_mark/level_free.
READ THE MANUAL CAREFULLY ON THESE COMMANDS! They can be deadly... but often necessary.

3> If you are using the commands ENT_CLONE or ENT_CLONESKIN, then there is no way
to prevent memore loss EXCEPT by using something from point#2.



BTW the way you are testing memory consumption is the best way IMHO...


I hope this helps somewhat...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial

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