Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Out of Memory Error : Java heap space

    Hi, I'm trying to export summary statistics from Stata 15.1 to a word document using the putdocx command. However after typing the command
    Code:
    putdocx table Table4=data(unique*), varnames
    , I get the error message "java.lang.OutOfMemoryError: Java heap space".

    Is there any way for me to clear up memory in Stata? My data set has only 10,000 observations.


    Thanks!

  • #2
    You can increase the amount of memory available to Java. On a 64 bit system with 64 bit Stata this a safe thing to do, but when using 32 bit Stata, you need to be careful. That is because the address space for the memory available to Stata is limited for 32 bit processes. As you increases the memory available to Java on 32 bit Stata, you are effectively taking it from other uses in Stata such as for dataset or matrix allocation. By now most people should be using 64 bit Stata. In Stata 15 we allocate 128 megabytes to Java on 32 bit systems and we allocate 384 megabytes to Java on 64 bit systems. The allocation only happens if you use a feature that requires Java, such as putdocx, import delimited, import fred, the project manager, etc. You can get information about Java with query java, including if Java has been initialized.

    Code:
    . query java
    -------------------------------------------------------------------------------
        Java system information
          Java initialized     no
        Advanced Java settings
          set java_heapmax     384m
          set java_vmpath      C:\Program Files (x86)\Stata15\utilities\java\window
    > s-x64\jre1.8.0_162\bin\server\jvm.dll
    If you have 32 bit Stata you might try doubling the allocation to 256 megabytes.

    Code:
    set java_heapmax 256m
    If you have 64 bit Stata I would set the memory to 1 gigabyte.

    Code:
    set java_heapmax 1g
    To find out if you have 32 bit or 64 bit Stata...

    Code:
    . about
    
    Stata/SE 15.1 for Windows (64-bit x86-64)
    Revision 06 Jun 2018
    Copyright 1985-2017 StataCorp LLC
    To set the java_heapmax back to the default you can...

    Code:
    . set java_heapmax
    (java_heapmax preference reset to default)
    Anytime you change a Java setting it will require you to restart Stata to take effect, but only if Java has been initialized. You can refer to query java to see if Java has been initialized, but the set commands will prompt you if a restart is required.

    Comment

    Working...
    X