Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

After installation Mathematica 8 for Linux takes more than 3GB in the /usr/local/Wolfram/ directory. I suspect that not all of it is relevant if I want to do some occasional computations. Are there subdirectories which can be deleted safely to save some space?

share|improve this question

migrated from stackoverflow.com May 29 '12 at 19:38

This question came from our site for professional and enthusiast programmers.

    
I don't know if this is safe, and I'm not going to try it here, but the SystemFiles/Kernel directory will have several subdirectories which have a 64-bit and a 32-bit version. If you are using a 32-bit system, you might try deleting the 64-bit versions. It should save a few hundred MB. –  Szabolcs May 29 '12 at 19:44
6  
If you have the (up-to-date) Java runtime installed separately to Mathematica, you could delete the copies of the JRE in SystemFiles/Java/<$SystemID>. I did this not so much to save space but because the versions Mathematica installs are never updated, and old versions of the JRE have serious security vulnerabilities. (And Java 7 is much faster than Java 6, so there might be some performance benefit.) I checked the Java 7 release notes to make sure there weren't any major incompatibilities before doing this and haven't had problems so far, but YMMV. –  Oleksandr R. May 30 '12 at 0:37
    
@user429540 Welcome to MMA.SE and thanks for registring here. Could you perhaps be challenged to come up with a slightly more imaginative name? –  Sjoerd C. de Vries May 30 '12 at 10:25
    
How do I change the name? A question for SE Meta? –  highsciguy May 30 '12 at 10:27
    
Click on your username in the middle of the bar on top of your window. This brings you to your profile page. Search for the "edit" tab. Click that and you can edit your settings. –  Sjoerd C. de Vries May 30 '12 at 10:34

4 Answers 4

up vote 14 down vote accepted
  1. You can save a lot of space in the Documentation directory by using Delete All Output on all the larger ones and by using disk compression. For example, the v7 documentation Notebook for ContourPlot is 27.7MB, but after deleting output it is only 192k, and after NTFS compression only 72k. Doing this will require evaluating the documentation page before you can see the examples, but it will easily save 500MB for version 7; probably more in later versions.

    You can modify this answer as per your needs to programmatically delete all the output cells from the notebooks in the Documentation directory.

  2. As Oleksandr suggests you can delete the SystemFiles/Java/<$SystemID> folder(s), which contain copies of the JVM, if you have Java installed separately, saving about 190MB of space. (Or, following point #3, about half that.)

  3. Initial testing indicates that core functionality is retained after deleting binaries for the other system type (32 or 64 bit) from SystemFiles\Kernel\Binaries, SystemFiles\FrontEnd\Binaries and SystemFiles\Converters\Binaries saving about 88MB for version 7.

Under Windows you can use WinDirStat to easily visualize the space allocation within a drive or directory tree. That page recommends KDirStat for Linux and Disk Inventory X for OS X.

share|improve this answer
5  
It's worth noting that SystemFiles/Java also contains some JAR files that might be needed (e.g. for activation of Mathematica after installation), so my suggestion isn't to delete this entire directory, but just the JVMs (which are in subdirectories named after the $SystemID they correspond to). I've edited accordingly. +1 for the suggestion wrt. the documentation, BTW--seems like both the safest and most effective option here. –  Oleksandr R. May 30 '12 at 3:15
    
@Oleksandr thanks for the fix; quite important! –  Mr.Wizard May 30 '12 at 7:01
    
WinDirStat is a nice program, but it's first-time run takes incredibily long. I seem to recall something like half an hour or so on a PC I installed it on last year. –  Sjoerd C. de Vries May 30 '12 at 10:07
    
@Sjoerd you mean for doing all files on the disk? Or some kind of self-compile? I cannot recall such an event. –  Mr.Wizard May 30 '12 at 10:09
    
Yes, all files on a disk. Something like 250 GB of files on a 350 GB disk in a 4 year old PC. –  Sjoerd C. de Vries May 30 '12 at 10:11

In general, you can delete directories that correspond to settings of $SystemID other than what you use. For example, I could delete the contents of

SystemFiles/Kernel/SystemResources/MacOSX-x86/

since Mathematica on my machine has "MacOSX-x86-64" as its $SystemID, so it will use the files in

SystemFiles/Kernel/SystemResources/MacOSX-x86-64/

Additionally, as an extreme measure, on OS X MathKernel is a universal binary:

> file MathKernel 
MathKernel: Mach-O universal binary with 2 architectures
MathKernel (for architecture i386): Mach-O executable i386
MathKernel (for architecture x86_64): Mach-O 64-bit executable x86_64

and you can use lipo(-suction, I presume) from a command line to thin it down:

lipo -extract i386 -output MathKernel32 MathKernel
lipo -extract x86_64 -output MathKernel64 MathKernel

and then rename the appropriate bitted kernel to MathKernel. On my system, this would save about 70 MB.

share|improve this answer

Since Windows doesn't display directory sizes for me I wrote a tiny utility to let Mathematica display them in a collapsible tree form (code at the bottom).

I opened up some candidates for deletion, but you should try them first by moving the specific directories out of the MMA directory structure. As Image_doctor said, the documentation is a good sized candidate, as well as the 32/64 bit versions of the binaries suggested by Szabolcs. Further candidates can be found in the Links directory (but don't touch the MathLink directory; many of the others are probably safe, but no guarantee).

Mathematica graphics

directoryTree[startDir_] :=
 Module[{names, dirs, files, sizeFiles, sizeDirs, sons},
  SetDirectory[startDir];
  names = FileNames[];
  dirs = Select[names, (FileType[#] == Directory &)];
  files = Complement[names, dirs];
  sizeFiles = Total[FileByteCount /@ files];
  sons = If[Length[dirs] > 0, directoryTree /@ dirs, {}];
  ResetDirectory[];
  sizeDirs = If[Length[sons] > 0, Total[sons[[All, 2 ;; 3]], 2], 0];
  {startDir, sizeFiles, sizeDirs, sons}
]

dirTreeView[{}] := ""
dirTreeView[dT_] := 
  OpenerView[
    {
     Row[{First[dT], " (", Length[dT[[4]]], ", ", Total@dT[[2 ;; 3]], ")"}], 
     Column[dirTreeView /@ dT[[4]], Frame -> All]
    }
  ]

dirTreeView@directoryTree[$InstallationDirectory]
share|improve this answer
1  
Also, if the OP cared for it, they could probably make it such that all hyperlinks to paclet:ref/Foo are replaced with http://reference.wolfram.com/mathematica/ref/Foo.html, so that Information (?) would take them directly to the page in a browser instead of giving an error (if they deleted the docs). The stored paclets used in ExampleData could possibly go too... –  rm -rf May 29 '12 at 22:31

Half of it appears to be in ../Documentation , you could delete that and look everything up on the Wolfram site on the web

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.