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

Watching allocs

grg99
Beginner
344 Views

Is there any approved way of peeking at the ALLOCATE and DEALLOCATE goings-on?

I've managed to kludge together some code that can log those commands, so we can catch memory leaks, but it's thru very non-standard ways.

Some readily accessible procedure hooks (EXTERNAL variables) would be wonderful.

Until then we'll have to hex edit "FOR_ALLOCATE" to "ACT_ALLOCATE" in the libraries and other less than sterling hacks.

Thanks,

George

0 Kudos
1 Reply
Jugoslav_Dujic
Valued Contributor II
344 Views
Here's a more elegant less inelegant hack of mine (for a different purpose, but mostly reusable); it works only for allocatables (not for pointers), as for_alloc_allocatable calls for_allocate (for pointers, for_allocate is called directly). I'm not sure at the moment whether there is one or two routines for deallocation.

Since you sound like a capable kludger hacker, you might tweak the idea further, by "subclassing" the for_allocate and for_deallocate routines:
  • Write your own for_allocate and for_deallocate routines, as I suggested there (you got the prototype for the first in that code, and you have to reverse-engineer the second by examining assembly code); maybe Steve will be kind enough to post it.
  • In those routines, do the logging and pass the arguments to the original for_allocate/for_deallocate. The easiest way is to
    • use dll version of run-time library (I assume you only need this for debugging, right?)
    • use GetModuleHandle("libifcorert.dll") and GetProcAddress to get a pointer to them
    • call them
Hope this helps,

0 Kudos
Reply