public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "xarthisius.kk at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/49241] memory leak with lhs realloc of zero-sized array
Date: Tue, 31 May 2011 15:34:00 -0000	[thread overview]
Message-ID: <bug-49241-4-PfYhnh8qea@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-49241-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49241

--- Comment #2 from Kacper Kowalik <xarthisius.kk at gmail dot com> 2011-05-31 15:12:19 UTC ---
(In reply to comment #1)
> The memory the program needs increases continuously as "top" shows; it takes
> about 5min on my computer before the OS kills it (out of memory).
> 
> If one does not use an endless loop but a finite loop, it shows no leakage with
> neither valgrind nor totalview. Also the result seems to be fine - except that
> the memory consumption simply grows ...
> 
> Slightly reduced test case:
It's not caused by reallocation, rather by array constructor? 
Test case without lhs realloc:

program ala
   implicit none
   type :: array_of_foo
      real, dimension(:), allocatable :: p
   end type array_of_foo
   type(array_of_foo), dimension(:), allocatable :: tab
   integer :: i, nn

   do
      allocate(tab(1:2))
      allocate(tab(1)%p(0))
      allocate(tab(2)%p(1))
      tab(2)%p(1) = 1.0

      nn = size( [tab(1)%p, tab(2)%p] )

      deallocate(tab(2)%p)
      deallocate(tab(1)%p)
      deallocate(tab)
   end do
end program ala


  parent reply	other threads:[~2011-05-31 15:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-31 11:19 [Bug fortran/49241] New: " xarthisius.kk at gmail dot com
2011-05-31 12:47 ` [Bug fortran/49241] " burnus at gcc dot gnu.org
2011-05-31 15:34 ` xarthisius.kk at gmail dot com [this message]
2012-02-22 13:43 ` xiaoyuanbo at yeah dot net
2012-12-22 16:30 ` Joost.VandeVondele at mat dot ethz.ch
2013-02-27 12:45 ` dominiq at lps dot ens.fr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-49241-4-PfYhnh8qea@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).