How do I delete a resource?

View previous topic View next topic Go down

How do I delete a resource?

Post  LuisLee on Tue Jun 02, 2009 3:00 am

e.g.

When entering the game.
Game process
As follows :
1 Logo Maps.
2 Menus.
3 GameStart.

When I entering the GameStart. I will delete Logo maps.
use sio2ResourceDel()? use sio2ImageFree()? use sio2WidgetFree()? I have tried each.However, no effect.
Memory space is unchanged.
How to do?
pale

LuisLee

Posts : 85
Join date : 2009-04-26
Age : 30

View user profile

Back to top Go down

Re: How do I delete a resource?

Post  sio2interactive on Tue Jun 02, 2009 3:30 am

This is how I free the resource of my game:

sio2ResourceUnload( udgame->_SIO2resource, SIO2_SOUND );

sio2ResourceUnloadAll( udgame->_SIO2resource );

udgame->_SIO2resource = sio2ResourceFree( udgame->_SIO2resource );

Notice that I remove all sound first since I have some sound created manually, it is necessary in order to avoid an OpenAL warning... However if the sound comes directly from a .sio2 this will not happen...

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: How do I delete a resource?

Post  LuisLee on Tue Jun 02, 2009 4:24 am

sio2interactive wrote:This is how I free the resource of my game:

sio2ResourceUnload( udgame->_SIO2resource, SIO2_SOUND );

sio2ResourceUnloadAll( udgame->_SIO2resource );

udgame->_SIO2resource = sio2ResourceFree( udgame->_SIO2resource );

Notice that I remove all sound first since I have some sound created manually, it is necessary in order to avoid an OpenAL warning... However if the sound comes directly from a .sio2 this will not happen...

Your way is to delete all of the resources, is it? I
but,I would like to delete the specified picture.
e.g.
I have a few logo picture.Names are "a.png","b.png" and so on. I will delete "a.png".How to do?
Sad
Before, my method is:
itMapWidget=m_pMapWidget.find("a.png");
sio2WidgetFree(itMapWidget->second);
Is wrong.

LuisLee

Posts : 85
Join date : 2009-04-26
Age : 30

View user profile

Back to top Go down

Re: How do I delete a resource?

Post  sio2interactive on Tue Jun 02, 2009 4:30 am

_SIO2resource = YOURRESOURCE THAT CONTAIN THE A.PNG ...

sio2->_SIO2resource = _SIO2resource

sio2ImageFree( sio2ResourceImageGet( _SIO2resource, "a.png" ) );
sio2ImageFree( sio2ResourceImageGet( _SIO2resource, "b.png" ) );
etc...

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: How do I delete a resource?

Post  LuisLee on Tue Jun 02, 2009 4:53 am

sio2interactive wrote:_SIO2resource = YOURRESOURCE THAT CONTAIN THE A.PNG ...

sio2->_SIO2resource = _SIO2resource

sio2ImageFree( sio2ResourceImageGet( _SIO2resource, "a.png" ) );
sio2ImageFree( sio2ResourceImageGet( _SIO2resource, "b.png" ) );
etc...

thank you! but I use this method

itMapWidget=m_pMapWidget.find("a.png");
sio2ImageFree(itMapWidget->second->_SIO2material->_SIO2image[ SIO2_MATERIAL_CHANNEL0]);

Smaller memory space( -4M). but There is no satisfactory results.
My method is this. Save the container widget with map pointer.The release of pictures when resources such as the above.This is the same effect?

LuisLee

Posts : 85
Join date : 2009-04-26
Age : 30

View user profile

Back to top Go down

Re: How do I delete a resource?

Post  sio2interactive on Tue Jun 02, 2009 5:11 am

Please define what you mean by:

>> Smaller memory space( -4M)

and then think about it for 10 seconds Wink

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: How do I delete a resource?

Post  _-MADMAN-_ on Tue Jun 02, 2009 7:16 am

If You now that object/image/whatever will be changed often, it's better to make global handlers for sio2resource "baskets" and simply unload and free them, and load into them something else after unload Wink

_-MADMAN-_

Posts : 52
Join date : 2009-04-23

View user profile

Back to top Go down

Re: How do I delete a resource?

Post  sio2interactive on Tue Jun 02, 2009 8:18 am

Totally... Just keep the sio2resource for the generic stuff but keep the handle of the dynamic or called often stuff...

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: How do I delete a resource?

Post  LuisLee on Tue Jun 02, 2009 7:07 pm

Very Happy Very Happy

Smaller memory space( -4M) Mean: 4mb of memory space reduction.

I did not make that clear. he~he~he

thank you for you help!!!!! Very Happy

LuisLee

Posts : 85
Join date : 2009-04-26
Age : 30

View user profile

Back to top Go down

Re: How do I delete a resource?

Post  sio2interactive on Tue Jun 02, 2009 7:25 pm

No Im asking why this:

itMapWidget=m_pMapWidget.find("a.png");
sio2ImageFree(itMapWidget->second->_SIO2material->_SIO2image[ SIO2_MATERIAL_CHANNEL0]);

Have a 4MB less of memory usage compare to the regular sio2ResourceGetImage function and SIO2resource storage... SIO2resource is really small by default (172 bytes) and take an extra 4 bytes for every handle... so Im telling you that you can load about 4 millions of handle before it reaches 4MB... If your .find method is the one of an std::vector, I can told you right there that the memory that you are consuming for the list is WAY bigger than the SIO2 method and the performance of the find function is no match compare to the sio2StringCmp search function...

This is why I was asking you to think at least 10 sec to backup your statement Wink

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: How do I delete a resource?

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum