Announcement

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

  • Temporary files "collide"

    Hey,

    I have a long script which I run on different instances (always with different settings for the calculations). It seems like some of the instances and the created temporary files "collide".

    I got the following two errors (each in one instance):
    Code:
    file
    C:\Users\username\AppData\Local\Temp\ST_04000002.tmp not found
    unable to restore data due to insufficient memory; try discard first
    unable to restore data due to insufficient memory; try discard first
    could not restore sort order because variables were dropped
    could not restore sort order because variables were dropped
    r(601);
    and

    Code:
    file
    C:\Users\username\AppData\Local\Temp\ST_04000002.tmp already exists
    post __000014 not found
    r(111);
    Do you have any idea where does the error come from and how to avoid it? Thanks in advance!

    edit:
    Additional information. I run/ran the script on four instances. Two run without an error, two not.
    Last edited by Thomas Mitterling; 15 Jul 2017, 08:38.

  • #2
    In case someone has the same problem. I think I started the instances "too fast" and Stata gave several of them the same number. You should be able to avoid this problem by waiting after the start of each instance until you start the next one.

    Comment


    • #3
      For Stata 16 (through at least 18):
      On flavors other than MP, `preserve` and `restore` still rely on saving data to disk in a way that can collide across instances. MP uses frames (introduced in Stata 16) instead. Other flavors could use frames to implement `preserve/restore`, but don't.

      Some commands I was using had embedded calls to `preserve/restore`, which caused an issue like OP's when running simultaneous instances of Stata.

      Here are very simple programs (no warranty) that should give an idea for someone wanting a drop-in replacement of `preserve` and `restore` on non-MP flavors of Stata:

      Code:
      program define frpreserve
          capture frame drop frpreserve_temp
          local current_frame = c(frame)
          frame copy `current_frame' frpreserve_temp
      end
      
      program define frrestore
          syntax [, NOT]
          local current_frame = c(frame)
          if "`not'" == "" {
              frame copy frpreserve_temp `current_frame', replace
          }
          frame drop frpreserve_temp
      end
      and you can substitute `frpreserve` for `preserve` and `frrestore` for `restore`. These have not been thoroughly tested and not all options are implemented, but you could modify the programs to add those.
      Last edited by Michael Harris differentiated; 26 Oct 2023, 07:52.

      Comment

      Working...
      X