- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Consider the two following examples:
SUBROUTINE S1
IMPLICIT NONE
INTEGER, POINTER :: P(:)
ALLOCATE(P(10))
END SUBROUTINE S1
SUBROUTINE S2
IMPLICIT NONE
INTEGER, ALLOCATABLE :: TEMP(:)
INTEGER, POINTER :: P(:)
ALLOCATE(TEMP(10))
P => TEMP
END SUBROUTINE S2
Is it correct to say that S1 leads to a memory leak whereas S2 does not?
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes.
(The TARGET attribute needs to be added to TEMP in S2.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ooops, yes I forgot TARGET (I didn't try to compile those two examples, hence the miss).
Thanks for confirming my understanding of this though! Very much appreciated.
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