Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
2 registered members (3run, AndrewAMD), 667 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
ptr_remove / memory question #344628
10/19/10 07:20
10/19/10 07:20
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hi,

usually I remove my panels using:

Code:
ptr_remove(pan);
pan = NULL;



Now I'm wondering what happens with the allocated memory used for the bmaps within this panel?

Do I have to remove them manually before removing the panel? Or is this done automatically during the ptr_remove(pan) call?

Is there any difference using ptr_remove(pan) or pan_remove(pan)?

Regards,
Pegamode.

Re: ptr_remove / memory question [Re: pegamode] #344630
10/19/10 08:06
10/19/10 08:06
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline
Senior Member
3dgs_snake  Offline
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
Hi,

I think the memory allocated to the BMAP is not destroyed when you call ptr_remove on the panel, because the BMAP is another object and should exist until you delete it explicitly (I think that you can use the same BMAP for different PANELS). If you don't need your BMAP anymore, you can 'ptr_remove' it. Anyway the BMAP will be removed when your game will close cause it's an engine object.

Re: ptr_remove / memory question [Re: pegamode] #344631
10/19/10 08:09
10/19/10 08:09
Joined: Apr 2006
Posts: 624
DEEP 13
badapple Offline
User
badapple  Offline
User

Joined: Apr 2006
Posts: 624
DEEP 13
i dont know about a8 , but with a6 i need to purge bmap's and entities before removing them or making them invisible , to reallocate the memory used by them back into free memory.

Re: ptr_remove / memory question [Re: badapple] #344632
10/19/10 08:22
10/19/10 08:22
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Can someone confirm this?

If so then the following define should do the trick, doesn't it?

Code:
#define _pan_remove(pan) if(pan->bmap != NULL) { bmap_purge(pan->bmap); ptr_remove(pan->bmap); pan->bmap = NULL; } if(pan->mouse_map != NULL) { bmap_purge(pan->mouse_map); ptr_remove(pan->mouse_map); pan->mouse_map = NULL; } if(pan->target_map != NULL) { bmap_purge(pan->target_map); ptr_remove(pan->target_map); pan->target_map = NULL; } ptr_remove(pan); pan = NULL



Regards,
Pegamode.

Re: ptr_remove / memory question [Re: badapple] #344633
10/19/10 08:25
10/19/10 08:25
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline
Senior Member
3dgs_snake  Offline
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
There are two choices for you if you want to ptr_remove a panel :
1 - ptr_remove the BMAP before the PANEL : You MUST set the PANEL's bmap pointer to NULL before removing the BMAP.

2 - ptr_remove the PANEL before the BMAP : You MUST have another pointer that points to the BMAP (You can get the PANEL bmap pointer just before releasing it).

Re: ptr_remove / memory question [Re: 3dgs_snake] #344634
10/19/10 08:32
10/19/10 08:32
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Why should I set the PANEL's bmap pointer to NULL ???

If I'd do that I would have to save the pointer somewhere else to remove the BMAP. That doesn't seem to make sense.

I think the only important thing is that the PANEL doesn't try to access the BMAP anymore after removing the pointer to the BMAP within the PANEL.

Re: ptr_remove / memory question [Re: pegamode] #344635
10/19/10 08:32
10/19/10 08:32
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline
Senior Member
3dgs_snake  Offline
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
I think yes, but you must be very careful. If other panels use your BMAPS and you free them, your application will crash.

Re: ptr_remove / memory question [Re: 3dgs_snake] #344636
10/19/10 08:35
10/19/10 08:35
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Yeah ... but most of my PANELs are created like this:

pan_create("bmap = background.pcx",1);

So the PANELs don't share the pointer to a BMAP.

Does someone know if there's a difference between ptr_remove and pan_remove ???

Re: ptr_remove / memory question [Re: pegamode] #344637
10/19/10 08:42
10/19/10 08:42
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline
Senior Member
3dgs_snake  Offline
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
What I say is true, and that really makes sens : if you remove the BMAP, its allocated memory will be freed by the engine but the panel bmap pointer will still point to it, so the crash.

Yes, You are right about the important thing, but how will you do it? I think that You will not throw in another BMAP (so the NULL thing).

Re: ptr_remove / memory question [Re: 3dgs_snake] #344638
10/19/10 08:50
10/19/10 08:50
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
I know that I should set the pointer tu NULL, but I don't see any reason why to do that before removing the BMAP.

Take a look at the code I posted:

Code:
if(pan->bmap != NULL) { 
bmap_purge(pan->bmap); 
ptr_remove(pan->bmap); 
pan->bmap = NULL; }



As you can see I set the bmap pointer to NULL AFTER removing the bmap.
If I call "pan->bmap = NULL;" before I couldn't call "bmap_purge(pan->bmap)" afterwards because "pan->bmap" points to NULL.

Page 1 of 2 1 2

Moderated by  HeelX, Spirit 

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