Bug introduced in 7.0 and fixed in 9.0.0
The functions GeoDirection and GeoDistance have memory leaks. To see this, run the example functions below and watch as the Physical Memory Available in the Windows Task Manager, Performance tab, monotonically decreases with function execution.
memoryLeakGeoDirection[x_] :=
Block[{},
Do[GeoDirection[{RandomReal[{5, 15}],
RandomReal[{105, 135}]}, {RandomReal[{20, 25}],
RandomReal[{140, 155}]}], {x}]]
memoryLeakGeoDirection[10000]
and
memoryLeakGeoDistance[x_] :=
Block[{},
Do[GeoDistance[{RandomReal[{5, 15}],
RandomReal[{105, 135}]}, {RandomReal[{20, 25}],
RandomReal[{140, 155}]}], {x}]]
memoryLeakGeoDistance[10000]
If one swaps GeoDirection or GeoDistance with any of GeoDestination, GeoPosition or Log, Sin, etc. then no memory loss occurs.
I have coded a large Monte Carlo simulation using GeoDirection and GeoDistance. To run the actual simulation it is necessary to call these functions on the order of 108 to 109 times. I have upgraded the RAM from 16 GB to 32 GB, and upgraded from Windows 7 Home Premium to Windows 7 Professional, all in a failed attempt to stay ahead of the leaking memory. I am using Mathematica 8.0.4.0 64 bit.
I have tried $HistoryLength = 0
and ClearSystemCache[]
, without success in recovering the leaking memory.
Do you have any suggestions as to how to recover this lost memory during a running simulation?