FIX: String Concatenation May Cause Memory ErrorsLast reviewed: September 16, 1997Article ID: Q105932 |
1.00 1.00a
MS-DOS
kbtool kbfixlist kbbuglist
The information in this article applies to:
SYMPTOMSCharacter string concatenations that involve the automatic creation of temporary variables may cause the following memory related run-time problems:
RESOLUTIONThis memory loss can be avoided by assigning the concatenated strings to a temporary character string variable.
STATUSMicrosoft has confirmed this to be a problem in FORTRAN PowerStation version 1.0. This problem has been resolved with FORTRAN PowerStation maintenance release version 1.0a for MS-DOS. FORTRAN PowerStation version 1.0 can be differentiated from the maintenance release version 1.0a by invoking the linker. Typing "link32 | more" from \F32\BIN directory will show version 2.8 for FORTRAN PowerStation version 1.0, and it will show version 1.0f for the maintenance release version 1.0a.
MORE INFORMATIONThe following two sample programs demonstrate a memory loss due to string concatenation in the argument list. In both of the following examples, using a temporary variable for the concatenated strings avoids the memory leak.
Sample Code 1C Compile options needed: none character*40 c1,c2 c1 = 'abcd' c2 = 'efgh' k = 0 do i=1,500000 if(c1//c2 .eq. 'Never') k = k + 1 end do endThe code above will run very slowly, and eventually generate:
run-time error F6700 - heap space limit exceeded Sample Code 2C Compile options needed: none character fmtout*20,label(1,3)*(9) double precision value data (label(1,j),j=1,3)/' Label',' Output',' Test'/ data value/3.14159/ fmtout='f10.3' write(6,'(3a,''='','//fmtout//')')(label(1,j),j=1,3),value endThe above code on execution will generate:
DOSXMSF : error DX2010: invalid pointer passed to free or realloc : 0005F0F8h. DOSXMSF : error DX2010: invalid pointer passed to free or realloc : 0005F0F8h. Label Output Test = 3.142The code does run to completion because this type of DOS-extender error is not fatal.
|
Additional reference words: 1.00 buglist1.00 fixlist1.00a
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |