Deallocating Memory to MS-DOS

Last reviewed: July 19, 1995
Article ID: Q48636
The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, versions 5.0 and 5.1
  • Microsoft FORTRAN PowerStation for MS-DOS, versions 1.0 and 1.0a

SUMMARY

When using the DEALLOCATE command the storage space reserved by ALLOCATE is not returned to the system. Yet, the space is free for use inside of the FORTRAN program.

MORE INFORMATION

To clarify the documentation, the memory allocated by the ALLOCATE instruction is held by the program until the program terminates. The DEALLOCATE instruction frees the memory for use inside the main program. The space is not returned to MS-DOS.

If you must have the memory deallocate back to MS-DOS, you can spawn to a child process where you ALLOCATE and DEALLOCATE. When the child process terminates, the memory that was claimed by the FORTRAN child process will be returned to MS-DOS.

The following code demonstrates this process:

Sample Code

C C Main file. C

      interface to integer*2 function spawnlp
     + [C,VARYING] (mode)
      integer*2 mode
      end
C
      integer*2 spawnlp
C
      I=spawnlp(0,loc('child.exe'C),loc('child.exe'C),
     Xint4(0))
      end
C----------------------------------------------------------

C---------------------------------------------------------- C Child process (separate file), called by spawnlp in C parent. C

      integer size
      character*1 arr1[allocatable] ()
      parameter (size=20000)
C
      allocate (arr1(size))
      DEALLOCATE (arr1)
      end
C----------------------------------------------------------


Additional reference words: kbinf 5.00 5.10 1.00
KBCategory: kbprg
KBSubcategory: FORTLngIss


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 19, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.