While looking at other things I did this small program that summaries the string memory
void main() { string x = ""; mapping m = ([]); do { x = _next(x); m[ (sizeof(x)*String.width(x))/1024*1024 ]++; } while( x!="2"); write("%O\n", m); }
and to my surprise there are some really large ones right at startup. Do they originate from the type system? Getting them to not be wide strings would be a great first step.
([ /* 33 elements */ 0: 2098, 1024: 76, 2048: 41, 3072: 26, 4096: 13, 5120: 14, 6144: 4, 7168: 4, 8192: 4, 9216: 3, 10240: 5, 11264: 2, 12288: 3, 13312: 4, 14336: 2, 15360: 1, 16384: 3, 17408: 2, 18432: 1, 20480: 1, 21504: 1, 22528: 1, 23552: 1, 25600: 1, 28672: 1, 30720: 1, 39936: 2, 59392: 1, 66560: 1, 71680: 1, 99328: 1, 117760: 1, 190464: 1 ])