Problema de memoria en algunos compiladores

Trabajo con un equipo con procesador i7 y windows 7 y con los compiladores Fortran Powerstation 4.0 y Microsoft Visual Studio 2008 con PGI Visual Fortran.
He observado que el siguiente código genera un problema de memoria (heap space) en el compilador Fortran Powerstation 4.0 (con PGI no). El error se produce al leer desde fichero valores un número grande de veces. En el administrador de tareas se puede observar que la memoria física sube sin parar hasta alcanzarse el error. Se incluye el código fuente más simple que ya genera el error (se han utilizado semáforos para comprobar que el bucle espera a la subrutina, se ha realizado reserva y liberación de memoria en la variable local “n” con la sentencia allocate y deallocate pero se tiene el mismo error).


program prueba
integer b,z

do z=1,10000000
call pu(b)


subroutine pu(b)
integer b,v,n(6)

40 format(6X,6(X,I5))

!Se pasa b por pasar un argumento

do v=1,j
read(10,40) n(1),n(4),n(2),n(5),n(3),n(6)

Fichero (malla.txt stuado en C:):

1 5 4 2 3 1 6
2 2 4 5 9 8 7
3 2 7 8 12 11 10
4 5 15 14 13 8 9
5 14 18 17 16 8 13
6 20 19 8 16 17 21
7 11 12 8 19 20 22
8 24 23 11 22 20 25
9 17 18 14 28 27 26
10 27 31 30 29 17 26

Se ha comprobado que el problema no está en abrir y cerrar el fichero sino en leer con el comando read. ¿A qué se puede deber este error?

Bablefish translation:

Working with a team with Intel i7 and windows 7 with Fortran Powerstation 4.0 and Microsoft Visual Studio 2008 with PGI Visual Fortran compilers. I noticed that the following code creates a problem of memory (heap space) in the Fortran Powerstation 4.0 compiler (with PGI does not). The error occurs while reading from file values a large number of times. In the Task Manager you can see physical memory upload without stopping until reaching the error. Includes the code simpler source that already generates error (traffic lights have been used to verify that the loop waits for the subroutine, has been reserve and release of memory in the local variable “n” with the statement to allocate and deallocate but it has the same mistake

Unfortunately, I don’t know but it does sound like a problem with the Fortran Powerstation compiler. Though, it could be an incompatibility with Windows 7 since Powerstation Station 4.0 is quite old. As far as I can tell, Microsoft no longer develops or supports Fortran Powerstation so I’m not sure who to send you to for help.

  • Mat

You are using an obsolete compiler, one which was somewhat buggy. Many Fortran compilers have small memory leaks in their run-time libraries, especially those that pertain to I/O.

By opening and closing a file 10 million times, you magnify this memory leak. From a certain point of view, you earned the rewards.

If you want to continue to use the MS compiler, open the file only once, check if it is open using the INQUIRE statement, and use REWIND as necessary.

Thank you very much for your quickly answer and the translation. I can’t write very well in English.

About what mkcolg explained I think that the problem is with the compiler too. But I am almost sure that the problem is not the operative system because I remenber to run the source code in Windows XP with the same problems.
With respect what mecej4 explained I know the compiler is obsolete. This is the reason why I use the PGI Visual Fortran. I had used the Digital Visual Fortran 6.0 and I have observed the same problems. The problem surely will be related with the small memory leaks you comment. I have tested what you said using the REWIND statement instead open and close the file iteratively. I have the same problems. By open and close the file 10 million times without reading the problem doesn’t exist. Then, the problem is when reading.

I know I have not knowledge enough with Fortran because I have not had lessons about it. Really I am very grateful to you for helping me though I were not able to solve my problems as you told me due to my lack of understand.