Mail Archives: pgcc/1999/08/19/18:01:58
Hi folks,
first of all, I'm not on the list, so any 'cc:' to me would be greatly
appreciated.
I think I discovered a bug, although I'm not sure that it is *really*
a pgcc bug, but then, gcc.486 does not show this behaviour.
It is kind of complicated because it involves NAG's Fortran95 (no it
is *not* their bug). The string concatenation hogs memory. This is
easily demonstrated by the following code:
Program MEMTEST
!
! Shows a memory leak when compiled with NAG f95 compiler.
!
use f90_unix_env
use f90_unix_proc
!
character :: command*32, text,dummy*32
integer :: pid
!
open(8,file='/dev/null')
pid=getpid() ! get process ID
write(command,'(i10)') pid
command='ps vp '//command
do n=1,100
write(8,*) 'sample ',n
do i=1,10000
text=' '
text=trim(text)//' abc' ! HOG
write(8,'(a)') text
end do
if (n == 1) call system(command) ! memory after first inner loop
end do
call system(command) ! memory after last inner loop
!
end program memtest
Depending on the existence of the line marked 'HOG' the program
allocates huge amounts of mem.
With HOG:
PID TTY STAT TIME PAGEIN TSIZ DSIZ RSS LIM %MEM COMMAND
29144 ? S 0:00 155 32 1343 536 xx 0.4 ./memtest
PID TTY STAT TIME PAGEIN TSIZ DSIZ RSS LIM %MEM COMMAND
29144 ? S 0:04 155 32 5211 4404 xx 3.4 ./memtest
Without HOG:
PID TTY STAT TIME PAGEIN TSIZ DSIZ RSS LIM %MEM COMMAND
29155 ? S 0:00 123 31 1304 492 xx 0.3 ./memtest
PID TTY STAT TIME PAGEIN TSIZ DSIZ RSS LIM %MEM COMMAND
29155 ? S 0:02 123 31 1304 492 xx 0.3 ./memtest
You might argue that this is not a bug at all, but then, using the
gcc.486 as the C-Compiler NAG_f95 uses, it becomes:
PID TTY STAT TIME PAGEIN TSIZ DSIZ RSS LIM %MEM COMMAND
29166 ? S 0:00 126 31 1304 504 xx 0.3 ./memtest
PID TTY STAT TIME PAGEIN TSIZ DSIZ RSS LIM %MEM COMMAND
29166 ? S 0:04 126 31 1304 504 xx 0.3 ./memtest
with and without the HOG-line.
For those of you not familiar with Fortran-syntax: '//' concatenates
strings, much as strcat() does.
The compilers in question are:
gcc version pgcc-2.91.66 19990314 (egcs-1.1.2 release)
and
gcc version 2.7.2.3
If it is of any help I can provide anyone with the preprocessed
.i-Files andør the preprocessed C files, f95 produces.
--
Oliver Jennrich JILA, University of Colorado @ Boulder
Gravity. It's not just a good idea, it's the law!
- Raw text -