Should you :Disconnect() GUI objects after using them?

If I didn’t disconnect an event from a GUI object, such as a TextButton (tb.MouseButtonDown:Connect()), would this cause a memory leak, and if so, how much of a problem is this?

1 Like

Are you speaking in terms of auto-generated buttons that get constantly refreshed and replaced? (drop-downs, selection lists, etc.) If so, using the :Destroy() function on any object also gets rid of any connections so you don’t have to worry about memory leaks.

If you’re speaking more along the lines of menu buttons that are simply put in the background when not in use, I doubt there would be enough buttons to cause any real memory issues.

2 Likes

I’m referring to the latter - if that’s the case, I should be fine then.

1 Like

I think you meant :Destroy()

4 Likes

aw crap I did

this is why I should preview my posts

1 Like