Huge memory leaks when importing two-dimensional array in Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg103462] Huge memory leaks when importing two-dimensional array in Mathematica
- From: Harut Amirjanyan <amirjanyan at gmail.com>
- Date: Wed, 23 Sep 2009 07:24:26 -0400 (EDT)
this isn' t memory leakage.It happens because after importing with "<<" t isn't packed array anymore. this can' t work at version 5 since v5 doesn' t have RandomReal function, you should have used something like Table[Random[Real, {-1, 1}], {10}, {2}] In[5] := MemoryInUse[] t = RandomReal[{-1, 1}, {100000, 2}]; Developer`PackedArrayQ@t MemoryInUse[] SetDirectory["C:/"] t >> temp.dat MemoryInUse[] Quit[] Out[5] = 10503248 Out[7] = True Out[8] = 12105640 Out[9] = "C:\\" Out[11] = 12111872 In[1] := MemoryInUse[] SetDirectory["C:/"] t = << temp.dat; Developer`PackedArrayQ@t MemoryInUse[] Quit[] Out[1] = 9921296 Out[2] = "C:\\" Out[4] = False Out[5] = 17540408 fastest way is to use DumpSave but then you can' t use your data with other system In[1] := MemoryInUse[] t = RandomReal[{-1, 1}, {100000, 2}]; Developer`PackedArrayQ@t MemoryInUse[] SetDirectory["C:/"] DumpSave["temp.mx", t]; MemoryInUse[] Quit[] Out[1] = 9922664 Out[3] = True Out[4] = 11540880 Out[5] = "C:\\" Out[7] = 11542760 In[1] := MemoryInUse[] SetDirectory["C:/"] Get["temp.mx"]; Developer`PackedArrayQ@t MemoryInUse[] Out[1] = 9921096 Out[2] = "C:\\" Out[4] = True Out[5] = 11539640