This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
strange memory leak
- From: mattias alveteg <Mattias dot Alveteg at chemeng dot lth dot se>
- To: fortran at gcc dot gnu dot org
- Date: Wed, 18 Oct 2006 14:17:37 +0200
- Subject: strange memory leak
- Dkim-signature: a=rsa-sha1; c=simple; d=chemeng.lth.se; s=MDaemon; t=1161173914; x=1161778714; q=dns; h=DomainKey-Signature: Received:Mime-Version:Content-Transfer-Encoding:Message-Id: Content-Type:To:From:Subject:Date; b=h2Ijam0/+l4R8MVEUCalq7ZOhmK CZ0lJx/UQRjmu843XwqOaZvrMF1KS/yg13qIVX3VXV4dJeB3OiVAh1+9mclJHxJL FXWr+Jec4sg1B77Bvf8In01rv6DXqst32VUF/ajQd6BAQZTQavJTx/dPMKjuvCXY X/Aem+N5kdCF4E8g=
- Domainkey-signature: a=rsa-sha1; s=MDaemon; d=chemeng.lth.se; c=simple; q=dns; h=message-id:from; b=gUikVpQ54u+DtGjFWo4fP2Y43xR+1cYF72mEQrY0+YOuisCAeNIHz/GbXO3u M3GnRJr8m9eebyAlRhqQMbfpXQdFnQo0KV+6RRXh2zUzKSAOAjD+R+LmN kMv7znMaTA4SwubT/6L0jYKf4r63Y1t1m0/wm5Z2HiMnY5Qpk5AeMo=;
Hi,
If the problem described below is already known, please ignore this
message:
I got runtime error messages when running some code, compiled with
GFortran 4.2.0 (2006-10-15) containing the following code (inside a
module)
subroutine EvaluateStateError(states1,error)
implicit none
real(rk),dimension(:,:),intent(in) :: states1
real(rk),intent(out) :: error
integer :: i(1),j(1)
real(rk) :: Diff(size(states1,1),size(states1,2))
error = maxval(abs(diff))
i=maxloc(abs(diff),dim=1)
j=maxloc(abs(diff),dim=2)
...
Changing the last 3 lines to this:
diff=abs(diff)
error = maxval(diff)
i=maxloc(diff,dim=1)
j=maxloc(diff,dim=2)
made the runtime error disappear. My guess is that some temporary
variable is created (since abs(diff) appears three times) and that
the compiler for some reasons tries to free that memory twice.
Since I found a workaround this has a rather low priority for me, but
please let me know if the problem is interesting enough that I should
try to isolate it (it'll take a few weeks before I have time to do that)
greetings
Mattias