Clearing RAM Memory during evaluation
- To: mathgroup at smc.vnet.net
- Subject: [mg111699] Clearing RAM Memory during evaluation
- From: Aaron Bramson <aaronbramson at gmail.com>
- Date: Tue, 10 Aug 2010 04:01:20 -0400 (EDT)
- Reply-to: aaronbramson at gmail.com
Hello Everybody, I am parsing a large data file and naturally this is memory intensive so I am breaking it into the smallest chunks possible. But I'm still having a problem with memory because I can't seem to clear up my RAM between chunks. So far there is NO output except writing a csv file, and I've cleared the main data-holding variable I use, and all of it is done inside a module...but still when the module finishes the memory isn't cleared. Quitting the kernel does clear the memory, but I can't do that in between calls of this function. Can anybody tell me what I need to change to get Mathematica to clear the memory at the end of the function? Here's the function: GetData[popdynamics_, simultaneous_, learning_] := Module[{ThisData, DataLine, DataFile}, ThisData = {}; DataLine = {}; DataFile = OpenRead[ "Experiment-table.csv"]; Do[DataLine = ReadList[DataFile, Record, 1], {7}]; DataLine = Map[StringTake[#, {2, StringLength[#] - 1}] &, ReadList[DataFile, Record, 36, RecordSeparators -> {",", "\n"}]]; While[DataLine != {}, If[(DataLine[[6]] == popdynamics) && (DataLine[[8]] == simultaneous) && (DataLine[[10]] == learning) , AppendTo[ThisData, DataLine]]; DataLine = Map[StringTake[#, {2, StringLength[#] - 1}] &, ReadList[DataFile, Record, 36, RecordSeparators -> {",", "\n"}]]; ]; If[ThisData != {}, Export["Test Data 2e.csv", ThisData]]; Close[DataFile]; ClearAll[ThisData]; ClearSystemCache[]; ] Here's the function call: GetData["true", "false", "true"]; Thanks in advance for your assistance, Aaron Bramson