Analyzers
Talk to fellow users of Intel Analyzer tools (Intel VTune™ Profiler, Intel Advisor)
4995 Discussions

Any success stories with memory leak detection in Fortran 2003/2008 code with allocatable components?

FortranFan
Honored Contributor II
307 Views

Hi,

Has anyone have been able to successfully use Intel Inspector on Fortran 2003/2008 code that makes use of Fortran ALLOCATABLE constructs (dynamically allocatable variables of intrinsic or derived type, derived types with allocatable components, etc.)?

As you may know, Fortran standard offers protection against memory leaks with the use of ALLOCATABLE constructs e.g., automatic deallocation of variables with local scope upon procedure termination, thereby coders can rest assure certain standard-compliant code can be free of leaks.

However when some of the standard-compliant code that can be expected to be leak-free per the reading of the standard are compiled with various versions of Intel Fortran compilers including the 2015 Beta, one finds leaks when run through other leak detection tools such as Valgrind or Dr. Memory - see an example of this at the Intel Fortran forum for Linux here.  However such leaks do not get detected by Intel Inspector, at least in many attempts I've made with different code, including the code in the said Linux forum topic.  My experience is full of false positives and false negatives.

Hence I was wondering if anyone had any success with Intel Inspector with any Fortran 2003/2008 code and if yes, if an example can be posted.  By the way, I contacted Intel staff about a month ago about this, but haven't received any actionable response yet.

Thanks in advance,

0 Kudos
2 Replies
Peter_W_Intel
Employee
307 Views

Thanks for your example code, I got expected result after running Inspector XE.

# ifort -v
ifort version 14.0.3

# inspxe-cl -version
Intel(R) Inspector XE 2013 Update 9 (build 328075) Command Line tool
Copyright (C) 2009-2013 Intel Corporation. All rights reserved.

 

# ifort -g fort_leak.f90 -o fort_leak -assume realloc_lhs
# inspxe-cl -c mi3 -- ./fort_leak
  
1 new problem(s) found 
    1 Memory leak problem(s) detected 
# inspxe-cl -report problem
P1: Error: Memory leak
 P1.3: Memory leak: 4 Bytes: New
  /home/peter/problem_report/fort_leak.f90(27): Error X3: Allocation site: Function obj_add: Module /home/peter/problem_report/fort_leak

Actually, "  allocate(C%i)" locates in function obj_add, it has not been freed. What I mean is local obj "C", isn't it an expected result?

You said, "...local scope upon procedure termination, thereby coders can rest assure certain standard-compliant code can be free of leaks." - did you mean that all leaks in local will be garbage-collected by the system? But I think that result was same as Valgrind's    

 

0 Kudos
Peter_W_Intel
Employee
307 Views

If you use 2015 Beta version, will get same result.

# inspxe-cl -version
Intel(R) Inspector XE 2015 Beta Update 1 (build 352351) Command Line tool
Copyright (C) 2009-2014 Intel Corporation. All rights reserved.

# ifort -v
ifort version 15.0.0 Beta

Note: if you use ifort v15.0 to build, and running Inspector XE 2013 to detect, leak can be detected but symbol (source line) info cannot be located - I encountered. 

 

 

0 Kudos
Reply