amar Singh <
jagter...@gmail.com> wrote:
> On Mar 19, 6:50?am, Andrew Haley <andre...@littlepinkcloud.invalid>
> wrote:
>> amar Singh <
jagteraho2...@gmail.com> wrote:
>> > The code I am running is a MPI process with 4 cores. it appears that
>> > there is a bug sitting in somewhere. Here's what I see:
>>
>> > as the code runs, its memory consumption increases. e.g. in the top
>> > command %MEM
>> > column increases in time. I suspect some variable is being allocated
>> > but not deallocated but I am not sure what is going on.. any
>> > suggestions to figure out would be appreciated. I used gfortran to
>> > compile the code so I am looking at an appropriate compiler switch or
>> > a strategy to use gdb or other debuggers to find what's going on.. the
>> > code crashes when left to run for a long enough time.....
>>
>> You have a memory leak; that much is obvious.
>>
>> We don't know what you know. Have you ever used gdb before? Any
>> debugger before? Have you any experience debugging large programs?
>> Etc...
>
> I have used gdb and other debuggers. Of course, I know there is a
> memory leak I want to know the gdb strategy to find which variable is
> doing it.
Right. I don't think there's any way to debug this without some
alteration to the program. I would begin by defining a wrapper for
malloc() that traces and logs allocations (and free()) along with the
caller. Look for blocks that are never freed. Calling backtrace()
from your malloc() wrapper tells you who is doing the allocation.
(Maybe fortran uses its own malloc, and you'd have to wrap that
instead. But you get the idea.)
Andrew.