Hi, I've been having issues with memory leaks in my program. I have boiled it down to this simple reproduction script:
class StringContainer extends Reference:
var string: String = "";
var cs = ;
for i in range(1024):
for q in range(256):
var nm := str(i).repeat(64) + str(q);
var c = StringContainer.new();
c.string = nm;
A bunch of StringContainer objects get added to the array
cs gets cleared. Since StringContainer extends Reference, clearing
cs should dereference all of the StringContainers, freeing the memory used.
The in-engine memory monitor suggests that this is happening correctly:
However, the memory monitor suggests otherwise; the memory use stays at around 580.2MiB at the end and never drops.
This doesn't happen if I replace
cs.append(nm);, the memory use grows and then drops back to <60MiB as expected.
How can I avoid this memory leak while storing the string within a class?