ID:1559657
 
(See the best response by Ter13.)
Code:
obj/crack
proc
Tick()
for(var/turf/floor/t in listOfExposedFloors)
t.ChangeColor()
spawn(5)
Tick()

turf/floor
proc
ChangeColor()
icon -= rgb(0,10,10)

Problem description:
The above code results in DreamSeeker growing by about 2000k every second. Is that expected? DreamSeeker keeps crashing every so often as well.

In profiler, when Tick is called 35 times, ChangeColor() is called about 4000 times as expected with 112 turfs in the list.
Best response
Is there any particular reason you are generating a new icon file in the cache for every object?

Why not use atom.color, or add an overlay?

You need to be caching and reusing data, not generating fresh, unique data for every single tile.
In response to Ter13
Ter13 wrote:
Is there any particular reason you are generating a new icon file in the cache for every object?

Why not use atom.color, or add an overlay?

You need to be caching and reusing data, not generating fresh, unique data for every single tile.

I edited my code to show that ChangeColor was actually apart of a different atom. As for you question, I didn't realize I was creating anything new. I thought I was changing the color of the current icon.
Rewrote it using color and it works great. No flickering, memory issues, and/or crashes. Thanks.