ID:1833482
 
BYOND Version:507
Operating System:Windows 7 Pro 64-bit
Web Browser:Chrome 42.0.2311.90
Applies to:Dream Seeker
Status: Open

Issue hasn't been assigned a status value.
507.1283
Descriptive Problem Summary:
Calling the function from Move() results in massive memory consumption. Windows eventually kills the process when it hits the 2gb mark.

Remarking i.Flip() prevents the problem.

To expedite the repro, I added multiple calls to HeroFlip() in Hero/Move()
Hero_Flip()
if (m_sDirection == "WEST")
m_sDirection = "EAST"
var/icon/i = new(src.icon)
i.Flip(EAST)
src.icon = i;
else
m_sDirection = "WEST"
var/icon/i = new(src.icon)
i.Flip(WEST)
src.icon = i;


Numbered Steps to Reproduce Problem:
Start the game
hold down the key 'd' to move the character right

Expected Results:
Memory shouldn't climb to 2gb in a few seconds.

Actual Results:
Memory consumption sky rockets to 2gb.

Notes:
Your probably still irked at me for the last rabbit-hole but I guess I'll have to take a chance.

The code is in shambles as I've been ripping it apart and putting it back together over and over. It could be a poor design issue and likely is. However, the fact that i.Flip() is the one causing the "leak" suggests it could be a bug.

Source was uploaded to the usual place.
Thanks. Looking into it now.

Incidentally most of that code can be done outside the if/else; flipping west is the same as flipping east, so the icon handling code is identical in both cases.
I see the problem here. This has to do with the client-side icon processing, in that the result after two separate flips is never recognized as matching the original icon.

This isn't so much a problem with Flip() as with all icon operations where the result matches an existing icon.

This looks like a challenging fix, but I'll nail it down eventually. I can probably handle some obvious cases without forcing the server into a full calculation. As a workaround in the meantime, my advice would be to cache your flipped icons so you only have to flip once.

var/list/_flipcache
proc/FlipCache(icon)
if(!_flipcache) _flipcache = new
. = _flipcache[icon]
if(!.)
var/icon/I = new(icon)
I.Flip(EAST)
. = fcopy_rsc(I)
_flipcache[icon] = .
_flipcache[.] = icon
Cool, I play around with that. Thanks.