Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

TexturePacker, Sprite Sheets, graphics and memory
Started by Pixin Jan 03 2018 12:01 PM

5 replies to this topic
texturepacker sprite sheet memory
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Pixin

[GLOBAL: userInfoPane.html]
Pixin
  • Contributor

  • 269 posts
  • Corona SDK

Thanks for checking out my question. I had a thought that's run rampant and now I've totally confused myself. ;)

 

Simple question: Does removing and nilling a single object from a sprite sheet really remove it from memory thus helping performance or is it still impacting performance since the entire sprite sheet is still required? (I use TexturePacker).

 

Would performance be better if I split the one-time sprites into one sheet and others into another and then un-require the whole sprite sheet for each screen once that screen is done?  For example, there are 5 different screens with some objects that are duplicated on every screen, but other objects that are permanently removed once the user goes to another screen.  So the thought occurred to me that if the objects are all on the same sprite sheet that is still required, does removing & nilling them help performance? (Yes, I have checked texture memory and I do see it reduced when removing an object, but still thinking, how does that work if the whole sprite sheet is required?)

 

Thanks for any help and to anyone who can set my mind back to normal. ;)

 

 



[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,587 posts
  • Corona SDK

You're conflating memory types I think.

 

There is main memory which is where your objects and Lua scripts are stored.

 

There is also video memory, which is where textures and texture data are stored (actually it's a bit more complicated than this).

 

Also, you don't nil objects from sprite-sheets.  You nil one of these:

- A variable referencing a image sheet

- A variable referencing a display objects.  Once you delete a display object and nil any and all references to it, Lua can garbage collect the remainder of the memory associated with that object at its (Lua's) leisure.

 

 

 

If you want to free memory associated with textures, learn more here: https://docs.coronalabs.com/guide/graphics/textureManagement.html


Edited by roaminggamer, 03 January 2018 - 12:11 PM.


[TOPIC: post.html]
#3

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,587 posts
  • Corona SDK

I failed to ask, but why do you need to worry about this?  Are you experiencing issues or are you pre-optimizing?  



[TOPIC: post.html]
#4

Pixin

[GLOBAL: userInfoPane.html]
Pixin
  • Contributor

  • 269 posts
  • Corona SDK

Right, that's what I knew, that I wasn't nilling the object, which started my mind racing with confusion about the memory - so I appreciate your explaining about that.  I wasn't experiencing issues but before I went on to the 2nd screen I wanted to be straight on it and make sure, since I have all my objects in tables and call them from there, based on the screen number.



[TOPIC: post.html]
#5

Pixin

[GLOBAL: userInfoPane.html]
Pixin
  • Contributor

  • 269 posts
  • Corona SDK

Thanks for the links - esp the Texture Loading/Management.  I did enjoy the premature optimization (while feeling guilty as charged ;) ).



[TOPIC: post.html]
#6

Pixin

[GLOBAL: userInfoPane.html]
Pixin
  • Contributor

  • 269 posts
  • Corona SDK

If I may ask, what happens then when a sprite sheet is "required". Is the whole sheet loaded into memory? Or is it just a reference to refer to when loading an image from that sprite sheet?




[topic_controls]
[/topic_controls]