This is why scripts need to be automatically managed.
I think there are 2 parts here:
- Automatic cleanup when a script ends
- Automatic cleanup (garbage collection) while a script is running, for resources that are no longer referenced
Both are mostly non-existent. 2 is tricky because you don’t always want to destroy a resource even if it is no longer referenced (Audio injectors are a good example, where you wouldn’t want it to be destroyed before the clip finished). That said, I (and probably most other devs) would agree that we should at least fulfill 1. I have it on my todo list to add automatic cleanup to overlays so they don’t stick around if you don’t clean them up or if the script crashes (!) before you even have a chance to clean them up (if other arguments for automatic cleanup aren’t convincing enough, I think the crash case should at least be).
The problem described in this post really shouldn’t exist, and is a bug, although it sounds like it isn’t a resource that the script is leaking, but an issue with textures being leaked or not being removed from the texture cache when they should be.
@humbletim Sorry if I hijacked your thread a bit here, this is some really awesome work!