Memory Leak with my Ray-Tracing plugin

Hello, I am having a problem with my ray tracing plugin. I had encountered the problem weeks from now, however, to that time I just ignored it as other stuff was more important. Anyway, now that I am looking towards to the release of the plugin I want to give the Users a good experience while using it.
The only thing is that the Ray-Tracing plugin I’ve made has a huge memory leak.

  1. What do you want to achieve? Keep it simple and clear!
    (Re-) rendering bigger scenes without studio crashing due to bad allocation (no RAM).

  2. What is the issue? Include screenshots / videos if possible!
    Whenever I rerender a scene, the memory used for the previous render is not garbage-collected. Meaning that just piling up. I am using Frames to draw the image produced by the Ray-Tracing algorithm. Whenever a new render starts, all those previous frames (up to 6k) get removed (They are parented to a folder, I use the :ClearAllChildren() method to remove all frames), it removes the frame but does not free the used memory.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Changing :ClearAllChildren() to :Destory() and :Remove()-method.

I have no idea why that is, I think it has to do with how roblox studio handles the collection of garbage on plugins.

Any help is appriciated!

3 Likes

I’ve seen games delete map models one-by-one, not plainly deleting them. Try deleting parts with a 0.2 delay

.2 second delay would be a bit much considering there are thousands of frames per render. Even with .002 it could take up to 12 seconds just to clear the previous render. I dont think that this solution would fit the plugin’s later Market.
Maybe waiting after every 100 frames or so, but it would still be a bit bulky for the user.

Thank you for the suggestion tho.

super sorry to bump this, but i’ve also got a large memory leak in my plugin for some reason

my plugin first creates a script where you import large encoded data into, and decodes it all of it (the script is immediately destroyed after the source is retrieved into a variable)

it does not create any connections or instances, and the variables it creates never get referenced after the data is fully decoded, so they SHOULD all be getting garbage collected

despite this, the memory seems to jump huge amounts permanently until i close and reopen the game in studio

i’ve searched through every module in my plugin, but i haven’t been able to find any possible cause of a memory leak, nothing that wouldn’t be garbage collected after they exit their scope

if there’s anyone who could provide info on why this could be happening i’d really appreciate it