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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (degenerate_762, AndrewAMD, Ayumi), 1,321 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
enough ptr_remove? #406930
09/02/12 08:25
09/02/12 08:25
Joined: Jan 2010
Posts: 150
iran - tehran
F
flatron Offline OP
Member
flatron  Offline OP
Member
F

Joined: Jan 2010
Posts: 150
iran - tehran
hi
I have a question.
BMAP* b1=bmap_create("test.bmp");

ptr_remove(b1) is enough to free memory or i have to use bmap_purge(b1) first?


Last edited by flatron; 09/02/12 08:28.
Re: enough ptr_remove? [Re: flatron] #406931
09/02/12 09:25
09/02/12 09:25
Joined: Apr 2006
Posts: 159
Latvija
Arrovs Offline
Member
Arrovs  Offline
Member

Joined: Apr 2006
Posts: 159
Latvija
its all vhat you need.


Arrovs once will publish game
Re: enough ptr_remove? [Re: Arrovs] #406933
09/02/12 10:42
09/02/12 10:42
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Thats right.

bmap_purge is seldom used.
It is mostly for memory minimisation by 'freeing' video memory used by
'seldom' access bmaps.

BMAP_remove is for 'truely' removing a bmap. I it does a bmap_purge during the remove process.

PTR_remove is for removing any object. I BELIEVE it will do a bmap_purge as I understand it...
I THINK the ptr_remove checks what type the object is, and then performs the
appropriate '???_remove' process. (ie bmap_remove, str_remove, ent_remove, etc)


Last edited by EvilSOB; 09/02/12 10:47.

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: enough ptr_remove? [Re: EvilSOB] #406936
09/02/12 12:51
09/02/12 12:51
Joined: Jan 2010
Posts: 150
iran - tehran
F
flatron Offline OP
Member
flatron  Offline OP
Member
F

Joined: Jan 2010
Posts: 150
iran - tehran
BMAP_remove dose not in 3dgs help.
is it a 3dgs command?

Re: enough ptr_remove? [Re: flatron] #406937
09/02/12 13:30
09/02/12 13:30
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
"bmap_remove(BMAP* image)" is a command, but its name is all lower-case...
I just put the 'BMAP' part of its name in capitals so it would be noticed.
bmap_remove has been around so long, I cant remember how old it is,
but Im pretty sure all lite-c versions have it.
!!BUT I COULD BE WRONG!!

[EDIT] After a bit of digging... I have discovered that bmap_remove was A7 ONLY,
and has been dropped entirely from A8... How did I not notice this?!?
It does not even exist in the obsolete syntax section of the manual...
Ah well... you learn something new every day...

And it goes to show how me using ptr_remove all the time for ANY
3DGS-object can be both a blessing and a curse at the same time...


Last edited by EvilSOB; 09/02/12 13:30.

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: enough ptr_remove? [Re: EvilSOB] #407200
09/09/12 07:34
09/09/12 07:34
Joined: Jan 2010
Posts: 150
iran - tehran
F
flatron Offline OP
Member
flatron  Offline OP
Member
F

Joined: Jan 2010
Posts: 150
iran - tehran
what about entities?
i test and seems ptr_remove dosen't enough for free memory.

Re: enough ptr_remove? [Re: flatron] #407201
09/09/12 08:10
09/09/12 08:10
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
I dunno for certain, but I believe it is OK.

Entities can be decieving because of the way acknex 'recycles' the memory they use.

Often you will completely and correctly remove an entity and all its resources,
but only a part of that memory get given back to the OS.
BUT, acknex will re-use that memory later even though there is no known (to me)
"user accessable" way of knowing the memory is currently sitting in
acknex's recycle bin... Its all to do with the way the nexus is managed.
(NOTE: When the engine exits, then ALL the memory is returned BTW)

To be able to test a similar problem with entities some time ago, I had
to set up a script that created around 100 entities per frame for about
10 frames, then remove the 10 oldest and create 10 new ones every frame.
This made the engine hover at around 1000 entities constantly being created,
living for 10 frames, and then being removed.

When I ran it the first time, it shocked me by climbing to nearly 700 Mb usage
in less than a minute... but then it dropped down ... and spiked to 800 ...
then dropped again ... and EVENTUALLY stabalised at around 400 mb.

This was with some very system-hungry models BTW.


So if you set up a script similar to mine above but use ptr_remove instead
of ent_remove, you can give it a valid test....
Set it running, stare in horror for the first minute, then walk away from it
and make a cup of coffee, or have a smoke (IF you are a smoker of course).

You could also set up a counter to register HOW MANY entities have been created
so far... That will make you feel better.

But in a nutshell, if it eventually crashes, there is a problem, but I
suspect that it will work fine, barring a few 'spikes' here and there.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: enough ptr_remove? [Re: EvilSOB] #407203
09/09/12 08:33
09/09/12 08:33
Joined: Jan 2010
Posts: 150
iran - tehran
F
flatron Offline OP
Member
flatron  Offline OP
Member
F

Joined: Jan 2010
Posts: 150
iran - tehran
there is a way to free memory and you can see it in taskmanager:
at first i have a model that has a 2048*2048 dds texture that make model size to about 4 mb.
so my code is :

///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <mtlFX.c>
///////////////////////////////
ENTITY* e1;
function rm(ENTITY* e2)
{
BMAP* bmap_temp=ent_getskin(e1,1);
if (bmap_temp!=NULL) ptr_remove(bmap_temp);
bmap_temp=ent_getskin(e1,2);
if (bmap_temp!=NULL) ptr_remove(bmap_temp);
ent_purge(e1);
ent_remove(e1);
ptr_remove(e1);
safe_remove(e1);
e1=NULL;
level_free();
level_mark();
}

function main()
{
level_load("");
wait(2);
level_mark();
e1=ent_create("CAM1-PAINT.mdl",vector(1000000,0,0),NULL);wait(-0.5);rm(e1);
e1=ent_create("......
and 40 lines like above for 40 other entites like that
}

I found the main code is level_free() and level_mark(). without these two ,memory increase a lot.


why there is not a command to delete a entity and free it's memory?
how can i check that my code free memory when engine , don't show me that.

Last edited by flatron; 09/09/12 08:40.
Re: enough ptr_remove? [Re: flatron] #407205
09/09/12 09:09
09/09/12 09:09
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
What you see in taskmanager if the amount of memory the application 'owns'.
It is not necessarily ALL in use as far as the application is concerned.
It can hold memory back from from the OS in RESERVE for it to use.

Level_free releases a set 'chunk' back to the OS when you tell it to.

Level_mark SETS a point in memory. When you then do a level_free, then
everything created AFTER that mark will be released.

Level_load releases it ALL, and starts afresh.

These three level_? commands are manually controlling the nexus, which is
the primary 'level' space used by the engine.

If you dig far enough back in the 'Ask the developers' forum you will find
a large discussion/argument between me and JCL on this issue, because
I wanted the nexes to be 'manipulatable' in the way you seem to.
THIS WILL NEVER HAPPEN!

In a nutshell, handling memory 'that way' is in-efficient and CAN add serious
cpu-overhead given commonly-occuring cercumstances. So JCL just isnt going to
go there. End of discussion.

BUT, the memory handling as it is now is more powerful, and more flexible than
is stated anywhere by anyone. And IF your situation allows you to actually
use level_mark etc, then it makes life very easy.


But ... if you cant or wont use the level_mark/level_free functions (like me)
then you are largely on your own, flying in the dark.

If you want to do MICRO-MANAGING things like checking if memory from a removed
entity HAS actually been freed, you need to write your own test routines.
There doesnt seem to be any way of telling the truth from looking at any of the
'system' variables that SHOULD report this information.

Maybe there IS a way, but Ive never found it, or anyone who knows it.


Do me a favour... Run the following script with your entity in place of
the "BLOB.MDL" in the 'ent_create' command. And tell me what happens...
And leave it running for 10 minutes if it can...

Click to reveal..
Code:
#include <acknex.h>
#include <default.c>
//
var i, counter=0;
//
action lifetime()	
{	vec_set(me.x, vector(random(100)-50,random(100)-50,random(100)-50));
	ent_clone(me);		counter++;		wait(100);		ptr_remove(me);		}
//
void main()
{
	wait(1);		level_load(NULL);		wait(1);			camera.x=-350;		def_debug();
	//
	while(1)
	{
		for(i=0; i<10; i++)		{	ent_create("blob.mdl",	nullvector, lifetime); 	}
		//
		DEBUG_VAR(counter, 100);
		//
		wait(1);
	}
}





"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: enough ptr_remove? [Re: EvilSOB] #407207
09/09/12 09:19
09/09/12 09:19
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
@EvilSob:
Quote:
Level_free releases a set 'chunk' back to the OS when you tell it to.

no it does not. level_free releases memory, that's true. but it releases this memory only to the engine/nexus
the nexus is some preallocated memory with a specific size
the engine itself does some really simple memory allocation algorithm which can't release any previously allocated memory. that's why you need level_free and level_mark. this is just some easy freeing of memory, but not releasing to the OS


Visit my site: www.masterq32.de
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