ButtonWidget causes texture memory leak

Hi Anderoth, Naomi,

Just for clarification, an image sheet is not “remove-able” via the typical methods ( removeSelf(), display.remove() ). It’s a userdata object, so does not apply to the display and removal from it. Proper removal should just involved nil’ing it out, as you recall from the old blog post Naomi.

Brent

Ah, okay, thank you, Brent.  So, just nil’ing would do the job then (and I was about to go back and change all of my code relating to image sheet disposal.)  I’m so glad you let us know just in time.  Now I don’t need to change my code.  * sigh of relief *

Naomi

You’re welcome Naomi! I have tested and confirmed that there is no memory leak if you properly nil out an image sheet.

Brent

Hi Brent,

What do you mean - no memory leak? So for you, texture memory usage that is printed in scene2 is zero? For me it’s not, event when image sheet is NILed in destroyScene in scene1. Maybe you haven’t uncommented creation of widget in scene1?

Also, guys, if you don’t know exactly what are you talking about, please defer from posting comments - it only pollutes the thread…

Hi @snikitin17,

I’ll probably need to test your actual code tomorrow. The issue is likely a scoping/cleanup error in your Storyboard setup, as the others in this post have suggested. My statement is based off core testing that I did internally, and recently, which shows that if an image sheet is properly nil’led out, there is no memory leak. That’s why I responded to Naomi and Anderoth to clarify that very specific point.

Best regards,

Brent

Thanks a lot Brent!

I am looking forward to your answer  :slight_smile:

Hi all,

I think I’ve figured out what is going on. Basically, you cannot rely on the memory being freed even after explicit collectgarbage call. Texture memory is redeemed later on correctly, there is no problem with button widgets.