- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm writing a tool that will help me find memory leaks.
After each allocate and deallocate statement I will paste a piece of code that uses LOC and SIZEOF to determine the address and size of the allocated block, and save info to a file.
I then sort the file and check for mismatches.
Am I correct to assume that this will work only for allocation of POINTERS and does not work with ALLOCATABLE arrays ?
After the first tests, it appears that it works ok for POINTER variables, but that allocatable arrays change address during execution.
Is this correct?
Why?
By the way, I'll be glad to share the tool with anyone interested after it's ready.
Thanks for any indications.
Marcello Cattaneo Adorno
After each allocate and deallocate statement I will paste a piece of code that uses LOC and SIZEOF to determine the address and size of the allocated block, and save info to a file.
I then sort the file and check for mismatches.
Am I correct to assume that this will work only for allocation of POINTERS and does not work with ALLOCATABLE arrays ?
After the first tests, it appears that it works ok for POINTER variables, but that allocatable arrays change address during execution.
Is this correct?
Why?
By the way, I'll be glad to share the tool with anyone interested after it's ready.
Thanks for any indications.
Marcello Cattaneo Adorno
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I know of no reason why these should be different. One an ALLOCATABLE array is allocated, it stays at the same address. It could be that the LOC intrinsic is returning the wrong thing.
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the answer. I'll work on it some more and get back to you.
I actually did two tests: the first on a simple linked list module, and it worked fine ( bust I had no allocatable arrays, only pointers).
Then I tried the utility on one module of a large simulation program that I'm writing, (with many allocatable arrays) and it failed to match LOC of allocation and deallocation in all cases!
If you confirm that ALLOCATABLE arrays behave like pointers in terms of staying in one place, then I'll have to find out what else vcan be happening.
regards, Marcello
I actually did two tests: the first on a simple linked list module, and it worked fine ( bust I had no allocatable arrays, only pointers).
Then I tried the utility on one module of a large simulation program that I'm writing, (with many allocatable arrays) and it failed to match LOC of allocation and deallocation in all cases!
If you confirm that ALLOCATABLE arrays behave like pointers in terms of staying in one place, then I'll have to find out what else vcan be happening.
regards, Marcello
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is a significant difference: In F95 (not F90), local ALLOCATABLE arrays (unless explicit SAVE is specified) are AUTOMATIC by default, i.e. they got deallocated when they exit the scope regardless of whether DEALLOCATE is called or not. Of course, when routine is reentered, address of such array will probably be different.
Jugoslav
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
True - once deallocated, all bets are off. But while allocated, the address doesn't change.
Steve
Steve

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page