Bug introduced in 11.0 and persisting through 11.1
It looks like Mathematica 11 stack tracing feature (see red ellipsis in front of any warning message) prevents garbage collector from removing temporary variables. For example the following code leaves three copies of hugeTempVar in memory after each evaluation.
test[a_]:= Module[{hugeTempVar},
hugeTempVar = ConstantArray[a, 1000];
a/0; (* some code which produces a message *)
a
];
Table[test[i], {i, 1, 10}];
Names[$Context<>"*$*"]
If one removes message-producing code a/0 there is no memory leak.
In this particular example, one can also use ParallelTable to enable old-style messages without stack trace an thus prevent memory leak.
I don't want to disable messages, because they provide important diagnostic information.
Is there a possibility to disable stack tracing, but keep messages?
hugeTempVar$541, it does show the codehugeTempVar$541 = ConstantArray[1, 1000]what doesn't require keeping the actual variablehugeTempVar$541. – Alexey Popkov 9 hours ago