12

A very abridged example of what was originally a major leak

{Animator[Dynamic@α, RefreshRate -> 120],
 Dynamic[arrows = (α; Arrow[{{0, 0}, {0., 1} + 0.001 RandomReal[2, 2]}]);],
 Dynamic[Graphics[arrows, ImageSize -> Tiny]
  ]}

I'm running Windows 7, x64, Mathematica 8.0.4. The Mathematica.exe process slowly (in this example) grows in memory usage and nothing I tried other than close and reopen Mathematica, seems to help.

Can you reproduce the problem? Is it known? What exactly is causing it? Any way to handle it?

I haven't got much experience in interfaces, but I had done a satisfactory one only to realise after a while it was using up 1.5GB of RAM

Rojo
  • 42,601
  • 7
  • 96
  • 188
  • How fast is the memory leaking on your machine for this example? I see something like 0.5 MB increase in memory/10 mins of running. – rm -rf May 30 '12 at 04:15
  • Ok, it gets faster at some point. Now it's at 250 MB after 1 hr. 8.04 on MacOSX. – rm -rf May 30 '12 at 05:16
  • Confirmed on version 7 under Windows 7. It is significantly worse with Animator[Dynamic@α, RefreshRate -> 120] – Mr.Wizard May 30 '12 at 05:30
  • Confirmed here too. Windows7-64, MMA 8.04. There's indeed a speed-up after some time. I'd say I lose about 1 MB/s (using Mr.Wizard's setting). – Sjoerd C. de Vries May 30 '12 at 10:43
  • I haven't had time yet to test more and answer, but I see that it's a shared concern. Actually I had done 2 interfaces and both had the issue, so my style clearly is buggy. I just mailed support@wolfram. Let's see – Rojo May 30 '12 at 17:47
  • This looks like a multi-platform/multi-version bug indeed. Could you report this to support@wolfram.com? – Sjoerd C. de Vries May 30 '12 at 10:48

2 Answers2

4

Reported, and forwarded to the developers. It is still there in v9

Rojo
  • 42,601
  • 7
  • 96
  • 188
3

It seems like it's the Graphics[arrows] part. This:

{Animator[Dynamic@\[Alpha], RefreshRate -> 120], 
 Dynamic[arrows = (\[Alpha]; 
     Arrow[{{0, 0}, {0., 1} + 0.001 RandomReal[2, 2]}]);], 
 Dynamic[Graphics[arrows];]}

Does not produce a memory leak for me: MMA 8.0.0 on Win7-64. Is it possible it is a history / Out[] type problem?

tkott
  • 4,939
  • 25
  • 44
  • I still get a memory leak with this but it's a slow one. I suppose it's related to this one where each unique object created is cached somehow. – Mr.Wizard May 30 '12 at 17:50
  • I even get a slow leak with {Animator[Dynamic@\[Alpha], RefreshRate -> 120], Dynamic[arrows = (\[Alpha]; Arrow[{{0, 0}, {0., 1}}]);], Dynamic[Null]} so there is perhaps a separate leak even without unique objects. – Mr.Wizard May 30 '12 at 17:53