(***********************************************************************

                    Mathematica-Compatible Notebook

This notebook can be used on any computer system with Mathematica 4.0,
MathReader 4.0, or any compatible application. The data for the notebook 
starts with the line containing stars above.

To get the notebook into a Mathematica-compatible application, do one of 
the following:

* Save the data starting with the line of stars above into a file
  with a name ending in .nb, then open the file inside the application;

* Copy the data starting with the line of stars above to the
  clipboard, then use the Paste menu command inside the application.

Data for notebooks contains only printable 7-bit ASCII and can be
sent directly in email or through ftp in text mode.  Newlines can be
CR, LF or CRLF (Unix, Macintosh or MS-DOS style).

NOTE: If you modify the data for this notebook not in a Mathematica-
compatible application, you must delete the line below containing the 
word CacheID, otherwise Mathematica-compatible applications may try to 
use invalid cache data.

For more information on notebooks and Mathematica-compatible 
applications, contact Wolfram Research:
  web: http://www.wolfram.com
  email: info@wolfram.com
  phone: +1-217-398-0700 (U.S.)

Notebook reader applications are available free of charge from 
Wolfram Research.
***********************************************************************)

(*CacheID: 232*)


(*NotebookFileLineBreakTest
NotebookFileLineBreakTest*)
(*NotebookOptionsPosition[      5770,        193]*)
(*NotebookOutlinePosition[      9035,        297]*)
(*  CellTagsIndexPosition[      8765,        282]*)
(*WindowFrame->Normal*)



Notebook[{
Cell[TextData[{
  "Utilities",
  StyleBox["`", "MB"],
  "MemoryConserve",
  StyleBox["`", "MB"]
}], "Subsection",
  CellTags->{"S6.11.1", "1.1"}],

Cell[TextData[{
  "On computers that have small amounts of installed memory, ",
  StyleBox["Mathematica", "TI"],
  "'s performance will begin to suffer after carrying out many \
memory\[Hyphen]intensive calculations. This package optimizes ",
  StyleBox["Mathematica", "TI"],
  "'s use of memory by automatically executing the kernel command ",
  StyleBox["Share[", "MR"],
  " ",
  StyleBox["]", "MR"],
  " whenever memory usage increases by a specified amount. \n",
  StyleBox["Share[", "MR"],
  " ",
  StyleBox["]", "MR"],
  " tries to minimize the memory used to store all expressions by sharing the \
storage of common subexpressions between different parts of an expression, or \
different expressions. Using ",
  StyleBox["Share[", "MR"],
  " ",
  StyleBox["]", "MR"],
  " will never affect the results you get from ",
  StyleBox["Mathematica", "TI"],
  ". It may, however, reduce the amount of memory used, and in many cases \
also the amount of time taken. Note, however, that the ",
  StyleBox["Share[", "MR"],
  " ",
  StyleBox["]", "MR"],
  " command itself may take some time to run. "
}], "Text",
  CellTags->{"S6.11.1", "1.2"}],

Cell[BoxData[
    FormBox[
      StyleBox[
        FrameBox[
          StyleBox[GridBox[{
                {"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"On[MemoryConserve]\\\\\\\"\
\\\", \\\"MR\\\"]\\) \"\>", "\<\"enable automatic memory conservation\"\>"},
                {"\<\"\\!\\(\\*StyleBox[\\\"\\\\\\\"Off[MemoryConserve]\\\\\\\
\"\\\", \\\"MR\\\"]\\) \"\>", "\<\"halt automatic memory conservation\"\>"}
                },
              ColumnAlignments->{Right, Left}],
            GridBoxOptions->{RowLines->False}]],
        "2ColumnBox"], TraditionalForm]], "Text",
  CellTags->{"S6.11.1", "1.3"}],

Cell["Commands for memory conservation. ", "Caption",
  CellTags->"S6.11.1"],

Cell["This loads the package. ", "MathCaption",
  CellTags->{"S6.11.1", "1.4"}],

Cell["<<Utilities`MemoryConserve`", "Input",
  CellLabel->"In[1]:= ",
  CellTags->"S6.11.1"],

Cell[TextData[{
  "When memory usage has increased by ",
  StyleBox["$MemoryIncrement", "MR"],
  " bytes ",
  StyleBox["Share[", "MR"],
  " ",
  StyleBox["]", "MR"],
  " will be run automatically. "
}], "MathCaption",
  CellTags->{"S6.11.1", "1.5"}],

Cell[CellGroupData[{

Cell["$MemoryIncrement", "Input",
  CellLabel->"In[2]:= ",
  CellTags->"S6.11.1"],

Cell[BoxData[
    \(100000\)], "Output",
  CellLabel->"Out[2]= ",
  CellTags->"S6.11.1"]
}, Open  ]],

Cell["\<\
This generates a large list containing multiple copies of the same \
expression. \
\>", "MathCaption",
  CellTags->{"S6.11.1", "1.6"}],

Cell["Table[ ToString[0], {2^15} ];", "Input",
  CellLabel->"In[3]:= ",
  CellTags->"S6.11.1"],

Cell[TextData[{
  "As you do subsequent calculations, ",
  StyleBox["Share[", "MR"],
  " ",
  StyleBox["]", "MR"],
  " is called and a significant amount of memory is freed up. The amount \
freed will vary from one computer system to another. "
}], "MathCaption",
  CellTags->{"S6.11.1", "1.7"}],

Cell[CellGroupData[{

Cell["Length[ % ]", "Input",
  CellLabel->"In[4]:= ",
  CellTags->"S6.11.1"],

Cell[BoxData[
    \(MemoryConserve::"start" \(\(:\)\(\ \)\) 
      "Running Share[] to conserve memory."\)], "Message",
  CellTags->"S6.11.1"],

Cell[BoxData[
    \(MemoryConserve::"end" \(\(:\)\(\ \)\) 
      "Finished running Share[]; \!\(614468\) bytes of memory freed."\)], \
"Message",
  CellTags->"S6.11.1"],

Cell[BoxData[
    \(32768\)], "Output",
  CellLabel->"Out[4]= ",
  CellTags->"S6.11.1"]
}, Open  ]],

Cell["This stops automatic memory conservation. ", "MathCaption",
  CellTags->{"S6.11.1", "1.8"}],

Cell["Off[ MemoryConserve ]", "Input",
  CellLabel->"In[5]:= ",
  CellTags->"S6.11.1"],

Cell["This restarts automatic memory conservation. ", "MathCaption",
  CellTags->{"S6.11.1", "1.9"}],

Cell["On[ MemoryConserve ]", "Input",
  CellLabel->"In[6]:= ",
  CellTags->"S6.11.1"]
},
FrontEndVersion->"4.0 for X",
ScreenRectangle->{{0, 800}, {0, 600}},
WindowSize->{520, 455},
WindowMargins->{{140, Automatic}, {Automatic, 72}},
StyleDefinitions -> "HelpBrowser.nb"
]


(***********************************************************************
Cached data follows.  If you edit this Notebook file directly, not using
Mathematica, you must remove the line containing CacheID at the top of 
the file.  The cache data will then be recreated when you save this file 
from within Mathematica.
***********************************************************************)

(*CellTagsOutline
CellTagsIndex->{
  "S6.11.1"->{
    Cell[1717, 49, 145, 6, 70, "Subsection",
      CellTags->{"S6.11.1", "1.1"}],
    Cell[1865, 57, 1141, 29, 70, "Text",
      CellTags->{"S6.11.1", "1.2"}],
    Cell[3009, 88, 599, 13, 70, "Text",
      CellTags->{"S6.11.1", "1.3"}],
    Cell[3611, 103, 76, 1, 70, "Caption",
      CellTags->"S6.11.1"],
    Cell[3690, 106, 79, 1, 70, "MathCaption",
      CellTags->{"S6.11.1", "1.4"}],
    Cell[3772, 109, 92, 2, 70, "Input",
      CellTags->"S6.11.1"],
    Cell[3867, 113, 249, 9, 70, "MathCaption",
      CellTags->{"S6.11.1", "1.5"}],
    Cell[4141, 126, 81, 2, 70, "Input",
      CellTags->"S6.11.1"],
    Cell[4225, 130, 88, 3, 70, "Output",
      CellTags->"S6.11.1"],
    Cell[4328, 136, 144, 4, 70, "MathCaption",
      CellTags->{"S6.11.1", "1.6"}],
    Cell[4475, 142, 94, 2, 70, "Input",
      CellTags->"S6.11.1"],
    Cell[4572, 146, 295, 8, 70, "MathCaption",
      CellTags->{"S6.11.1", "1.7"}],
    Cell[4892, 158, 76, 2, 70, "Input",
      CellTags->"S6.11.1"],
    Cell[4971, 162, 142, 3, 70, "Message",
      CellTags->"S6.11.1"],
    Cell[5116, 167, 168, 4, 70, "Message",
      CellTags->"S6.11.1"],
    Cell[5287, 173, 87, 3, 70, "Output",
      CellTags->"S6.11.1"],
    Cell[5389, 179, 97, 1, 70, "MathCaption",
      CellTags->{"S6.11.1", "1.8"}],
    Cell[5489, 182, 86, 2, 70, "Input",
      CellTags->"S6.11.1"],
    Cell[5578, 186, 100, 1, 70, "MathCaption",
      CellTags->{"S6.11.1", "1.9"}],
    Cell[5681, 189, 85, 2, 70, "Input",
      CellTags->"S6.11.1"]},
  "1.1"->{
    Cell[1717, 49, 145, 6, 70, "Subsection",
      CellTags->{"S6.11.1", "1.1"}]},
  "1.2"->{
    Cell[1865, 57, 1141, 29, 70, "Text",
      CellTags->{"S6.11.1", "1.2"}]},
  "1.3"->{
    Cell[3009, 88, 599, 13, 70, "Text",
      CellTags->{"S6.11.1", "1.3"}]},
  "1.4"->{
    Cell[3690, 106, 79, 1, 70, "MathCaption",
      CellTags->{"S6.11.1", "1.4"}]},
  "1.5"->{
    Cell[3867, 113, 249, 9, 70, "MathCaption",
      CellTags->{"S6.11.1", "1.5"}]},
  "1.6"->{
    Cell[4328, 136, 144, 4, 70, "MathCaption",
      CellTags->{"S6.11.1", "1.6"}]},
  "1.7"->{
    Cell[4572, 146, 295, 8, 70, "MathCaption",
      CellTags->{"S6.11.1", "1.7"}]},
  "1.8"->{
    Cell[5389, 179, 97, 1, 70, "MathCaption",
      CellTags->{"S6.11.1", "1.8"}]},
  "1.9"->{
    Cell[5578, 186, 100, 1, 70, "MathCaption",
      CellTags->{"S6.11.1", "1.9"}]}
  }
*)

(*CellTagsIndex
CellTagsIndex->{
  {"S6.11.1", 6395, 210},
  {"1.1", 7904, 251},
  {"1.2", 7998, 254},
  {"1.3", 8088, 257},
  {"1.4", 8177, 260},
  {"1.5", 8272, 263},
  {"1.6", 8368, 266},
  {"1.7", 8464, 269},
  {"1.8", 8560, 272},
  {"1.9", 8655, 275}
  }
*)

(*NotebookFileOutline
Notebook[{
Cell[1717, 49, 145, 6, 70, "Subsection",
  CellTags->{"S6.11.1", "1.1"}],
Cell[1865, 57, 1141, 29, 70, "Text",
  CellTags->{"S6.11.1", "1.2"}],
Cell[3009, 88, 599, 13, 70, "Text",
  CellTags->{"S6.11.1", "1.3"}],
Cell[3611, 103, 76, 1, 70, "Caption",
  CellTags->"S6.11.1"],
Cell[3690, 106, 79, 1, 70, "MathCaption",
  CellTags->{"S6.11.1", "1.4"}],
Cell[3772, 109, 92, 2, 70, "Input",
  CellTags->"S6.11.1"],
Cell[3867, 113, 249, 9, 70, "MathCaption",
  CellTags->{"S6.11.1", "1.5"}],

Cell[CellGroupData[{
Cell[4141, 126, 81, 2, 70, "Input",
  CellTags->"S6.11.1"],
Cell[4225, 130, 88, 3, 70, "Output",
  CellTags->"S6.11.1"]
}, Open  ]],
Cell[4328, 136, 144, 4, 70, "MathCaption",
  CellTags->{"S6.11.1", "1.6"}],
Cell[4475, 142, 94, 2, 70, "Input",
  CellTags->"S6.11.1"],
Cell[4572, 146, 295, 8, 70, "MathCaption",
  CellTags->{"S6.11.1", "1.7"}],

Cell[CellGroupData[{
Cell[4892, 158, 76, 2, 70, "Input",
  CellTags->"S6.11.1"],
Cell[4971, 162, 142, 3, 70, "Message",
  CellTags->"S6.11.1"],
Cell[5116, 167, 168, 4, 70, "Message",
  CellTags->"S6.11.1"],
Cell[5287, 173, 87, 3, 70, "Output",
  CellTags->"S6.11.1"]
}, Open  ]],
Cell[5389, 179, 97, 1, 70, "MathCaption",
  CellTags->{"S6.11.1", "1.8"}],
Cell[5489, 182, 86, 2, 70, "Input",
  CellTags->"S6.11.1"],
Cell[5578, 186, 100, 1, 70, "MathCaption",
  CellTags->{"S6.11.1", "1.9"}],
Cell[5681, 189, 85, 2, 70, "Input",
  CellTags->"S6.11.1"]
}
]
*)




(***********************************************************************
End of Mathematica Notebook file.
***********************************************************************)

