Changing the color (or perhaps appearance in general) of an atom leaks a small amount of memory. Rapidly changing the color of numerous atoms makes the leaking memory obvious.
Code Snippet (if applicable) to Reproduce Problem:
// This snippet randomizes the color of every turf every decisecond
// The turfs don't have icons, but that doesn't seem to matter
/world
maxx = 50 // Only relevant for how quickly memory is consumed
maxy = 50
/client/New()
. = ..()
spawn()
while(src)
for(var/turf/T)
T.color = list(rand(), rand(), rand(), rand(), rand(), rand(), rand(), rand(), rand())
// This also works, but seems to slow down before consuming too much memory:
// T.color = rgb(rand(255),rand(255),rand(255))
sleep(1)
Expected Results:
Memory usage would remain fairly consistent.
Actual Results:
- Usually, memory usage climbs at a modest pace (several MB each second), eventually reaching the limit and crashing Dream Daemon.
- Stopping the world may free some of the memory, or may crash DD. Attempting to re-start the world and reconnect usually causes it to hang or crash.
- Sometimes, DD will stop responding to the client shortly after connecting. Attempting to stop it will cause it to hang on "closing world", and attempting to exit will cause it to crash.
When does the problem NOT occur?
When the color var is not modified inside the loop.
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
507.1286 seems to exhibit the problem (with RGB instead of a color matrix, of course). 505.1235 would not let me connect at all, and I'm not sure why. I did not attempt to go back further.
I also tested 511.1373, and the problem still exists.
Workarounds:
Less frequent changing of colors, and more frequent restarting of Dream Daemon to clear out leaked memory.