title: How to increase memory limitations in Octave
body: <blockquote>
    <p>error: out of memory or dimension too large for Octave's index type</p>
  </blockquote>
  
  <p>According to the official <a href="https://www.gnu.org/software/octave/doc/v4.0.0/How-can-I-handle-memory-limitations_003f.html" rel="nofollow">docs</a>, I need to add a line like <code>-Xmx2048m</code> to file <code>java.opts</code>.</p>
  
  <blockquote>
    <p>"The directory where the Java options file is located is specified by
    the environment variable OCTAVE_JAVA_DIR."</p>
  </blockquote>
  
  <p>I don't have an environment variable with that name.</p>
  
  <blockquote>
    <p>If unset the directory where javaclasspath.m resides is used instead
    (typically OCTAVE_HOME/share/octave/OCTAVE_VERSION/m/java/). You can
    find this directory by executing <code>which javaclasspath</code></p>
  </blockquote>
  
  <p>That command doesn't work either (returns "which: no javaclasspath in ...")</p>
  
  <p>I found what looks like the correct directory, but it doesn't have a file called <code>java.opts</code>. I created the file and added that line to it, but I'm still running into the same memory limitation error. I confirmed that the issue is not related to "dimension too large" and I restarted Octave several times.</p>
  
  <p>How can I increase the memory limit in Octave?</p>