# Memory leak when looping over FindInstance in version 10.0.0

Bug introduced in 10.0 and fixed in 10.1

When I run the following (simplified) code with FindInstance, my MemoryInUse is constantly increasing:

\$HistoryLength = 0
Monitor[
Do[
FindInstance[x + y == 100, {y}];
memory = MemoryInUse[],
{x, 1, 1000}]
, memory]


I figured maybe there was some cache behavior that was accumulating memory, but I haven't had any luck with ClearSystemCache. I don't see anything particularly helpful in the FindInstance help. Any ideas?

I'm using 10.0.0 student edition on Windows 8.

Update: It seems (from the comments) that it might be a version issue or something specific to my setup. If anybody can reproduce this (i.e. memory increasing linearly throughout the loop), please comment.

Update 2: I upgraded from 10.0.0 to 10.0.2 and the leak in the test above disappeared -- memory usage now plateaus immediately and remains (roughly) constant throughout the loop. Unfortunately it still seems to leak in my actual code. When I comment out the FindInstance line (which has nothing else on it), memory is constant across loop iterations, but it's linearly increasing across the iterations when I leave FindInstance in there.

Update 3: I upgraded from 10.0.2 to 10.1.0 and now the issue is gone entirely -- memory is constant across loop iterations both in the test code and my actual code.

• Which version are you using? Does not occur in 9.0.1. (Or, rather, it quickly reaches a plateau and does not increase any further.) Apr 20 '15 at 17:21
• I'm not seeing such a leak in 10.0.2 or 10.1.0. I'm also not sure your test is appropriate. A better test is to check MemoryInUse[] before and after the Do loop is performed. Repeatedly running this test reveals no leaks that I can see. Apr 20 '15 at 17:24
• I'm using 10.0.0 student edition of Windows 8. For me, MemoryInUse just increases linearly throughout the loop. @StefanR - the issue is that in the real application, I run out of memory before completing the desired number of iterations in the loop, hence my interest in the memory usage within the loop, which should logically be constant across the iterations. Apr 20 '15 at 17:32
• On my friend's Apple 9.0.1, it immediately plateaus as Oleksandr R. describes, so maybe it is a version issue. Strange. Apr 20 '15 at 17:37
• We have the same problem on Mathematica 11.0.1 for Linux x86 (64-bit) Mar 20 '19 at 11:36