#Garbage Collection

1 messages · Page 1 of 1 (latest)

wide pine
#

A little time ago I create a custom TweenService for my game and I have a doubt, apparently I've been testing the game to its extremes conditions and seems like there is memory leaks of practically all the Tweens? being not garbage collected I think. Why does this happen? and if you have any doubt or got any important info about this or something tell me

mossy bronze
wide pine
#

and Idk why it is not doing his work

mossy bronze
#

you shouldn’t be relying on the gc to fix your optimization errors in the first place

wide pine
#

I mean I cannot do more, there are no references to these Tweens so I really cannot do nth

mossy bronze
#

you can just create a connection to tween.completed at the same time the tween is created

wide pine
#

I have a method which is CleanPlay that what it does is connect to the Completed a function to Destroy it instantly when its completed

The thing is when a Tween stop another Tween for X reason, there is where I need the GC to work or maybe a lightful idea Idk

mossy bronze
#

.completed will still fire if the tween is interrupted by another tween

wide pine
#

I don't fire the completed because it is not completed, should I? because I think that's not how the real Tweens works

wide pine
#

Solved, a reference still there lol

tough quiver
tough quiver
#

e.g part:Destroy() part:Clone().Parent=workspace works just fine. part:Destroy() doesn't actually destroy it, it just parents it to nil and you cannot re-parent it. you could do the same thing by doing part.Parent=nil. this is why sometimes certain instances dont need a parent to function

#

e.g Animation objects can be loaded by an animator even if the animation doesnt have a parent.

tough quiver
#

so if you tween position and color, then make another tween that tweens only color, the position tween should continue but the color will be overridden

wide pine
wide pine
tough quiver
#

idk what cleanplay is but basically all u gotta do is set things to nil or let them go out of scope to make them eligible for garbage collection

wide pine
tough quiver
#

dont install dumb 3rd party modules for gc. just clean up after yourself its not that hard

wide pine
#

I'm just saying which option would be the best

tough quiver
#

i think you overlooked the part when things also get garbage collected when they go out of scope