Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28615 Discussions

memory leaks or something like that...

mgpinedocuba
Beginner
357 Views

I was trying to implement a Fortran program for a Monte-Carlo simulation that uses many subroutine calls. Then, I noticed that my RAM was increasing with each iteration. I used Valgrind with my code and realized that there were a lot of memory leaks. So, I tried to rebuild my code but using Valgrind as a tool to check for possible memory leaks. That way I found a simple code like, for example, the following:

program main
  implicit none
  integer :: hello
  hello = 1
  hello = hello + 1
  write(*,"(I7)") hello
end program main
 
produce the following:

==26944== HEAP SUMMARY: ==26944== in use at exit: 0 bytes in 0 blocks ==26944== total heap usage: 7 allocs, 7 frees, 12,623 bytes allocated ==26944== ==26944== All heap blocks were freed -- no leaks are possible ==26944== ==26944== Use --track-origins=yes to see where uninitialised values come from ==26944== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) ==26944== ==26944== 1 errors in context 1 of 1: ==26944== Conditional jump or move depends on uninitialised value(s) ==26944== at 0x486021: __intel_sse2_strcpy (in /home/mgpc/git/MCSASHModel/src/adaptative/development/main.x) ==26944== by 0x43350E: for__add_to_lf_table (in /home/mgpc/git/MCSASHModel/src/adaptative/development/main.x) ==26944== by 0x44FC5B: for__open_proc (in /home/mgpc/git/MCSASHModel/src/adaptative/development/main.x) ==26944== by 0x43A6A4: for__open_default (in /home/mgpc/git/MCSASHModel/src/adaptative/development/main.x) ==26944== by 0x40DC39: for_write_seq_lis (in /home/mgpc/git/MCSASHModel/src/adaptative/development/main.x) ==26944== by 0x4038F6: MAIN__ (main.f90:5) ==26944== by 0x403861: main (in /home/mgpc/git/MCSASHModel/src/adaptative/development/main.x) ==26944== ==26944== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
 
when I compile that naybe program with the ifort compiler (one error), but when I used gfortran compile, It doesn't produce any error:
==27186== Memcheck, a memory error detector
==27186== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==27186== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==27186== Command: ./main.x
==27186==
2
==27186==
==27186== HEAP SUMMARY:
==27186== in use at exit: 0 bytes in 0 blocks
==27186== total heap usage: 23 allocs, 23 frees, 17,765 bytes allocated
==27186==
==27186== All heap blocks were freed -- no leaks are possible
==27186==
==27186== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
What's happening??
0 Kudos
2 Replies
Barbara_P_Intel
Employee
294 Views

Which Intel Fortran compiler are you using? What version? What are your compiler options?

 

0 Kudos
andrew_4619
Honored Contributor III
287 Views

This recent thread https://community.intel.com/t5/Intel-Fortran-Compiler/Using-a-Tree-Structure/m-p/1528910#M168368 also reports "Conditional jump or move depends on uninitialised value(s)"

 

0 Kudos
Reply