| Re: Auto-testing for memory leaks. |
|
 |
|
 |
|
 |
|
 |
Group: comp.lang.fortran · Group Profile
Author: Paul van DelstPaul van Delst Date: Sep 5, 2008 10:15
Paul van Delst wrote:
> Hello,
>
> I have a bunch of derived types that contain pointer arrays. In the
> course of their use the structures get allocated, copied, destroyed,
> reallocated, extended, etc.
>
> I test for memory leaks in a rather brain dead way - I call the routines
> in my test code many 10's of 1000's of times with top running in another
> window so I can keep an eye on the memory usage. If it increases
> steadily, I have a leak.
>
> But, I was wondering if anyone out there had any smarter ideas for
> testing this? Needing to run top alongside doesn't make for a very easy
> to use test.
>
> Thanks for any ideas.
Apologies for replying to my own post, but our news server has been very spotty of late so
I haven't received any replies locally and have been checking google groups.
To the poster rusi_pathan: thankyouthankyouthankyou! :o)
I went to the valgrind page, downloaded it, discovered it was already installed on my
linux system, recompiled my test prog, used the memchecker, and got immediate detailed
results! No memory leaks. Woohoo! I even deliberately buggered up my code to leak memory,
re-ran and there it was:
==26613== 41,600 bytes in 52 blocks are definitely lost in loss record 3 of 13
==26613== at 0x4004405: malloc (vg_replace_malloc.c:149)
==26613== by 0x805E3C6: __crtm_atmosphere_define_MOD_allocate_scalar
(CRTM_Atmosphere_Define.f90:1269)
==26613== by 0x806FB68: __crtm_atmosphere_binary_io_MOD_read_record
(CRTM_Atmosphere_Binary_IO.f90:1088)
==26613== by 0x8075D60: __crtm_atmosphere_binary_io_MOD_read_atmosphere_rank1
(CRTM_Atmosphere_Binary_IO.f90:438)
==26613== by 0x808B40B: MAIN__ (Test_Atmosphere.f90:407)
==26613== by 0x808B73D: main (fmain.c:21)
...etc...
Crikey! What a great tool! How come I never tried this before? I can't wait to try the
profiler!
Cheers... and thanks again.
paulv
|