I want to load a gif in ursina engine using the Animation class, it works flawlessly but when I want to reassign the Animation to another gif the memory stacks up like if I opened another gif. I tried to delete the instance and then recreate the gif but the memory keeps stacking up, also I tried to force a garbage collection but it doesn't work either. What can I do? The code is something like this:
from ursina import *
from ursina.prefabs.animation import Animation
import gc
app = Ursina()
FC={"FC":80}
monitor = Animation("monitor\gifs\monitor-%d.gif" % (FC["FC"]),loop=False)
monitor.enable()
def recreate_monitor():
global monitor
monitor = Animation("monitor\gifs\monitor-%d.gif" % (FC["FC"]),loop=False)
monitor.enabled = True
def refresh_monitor():
global monitor
monitor.sequence.start()
def update():
global monitor
if not monitor:
create_monitor()
else:
if monitor.sequence.finished:
if FC["FC"] != 80:
monitor.remove_node()
del monitor
print("DATA RECOLLECTED: ", gc.collect())
create_monitor()
else:
refresh_monitor()
def input(key):
if key == "space":
FC["FC"] = 100
app.run()