unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* potential memory leak in do loop
@ 2006-05-02 20:33 Stephane Chatigny
  2006-05-03  1:48 ` Kevin Ryde
  0 siblings, 1 reply; 6+ messages in thread
From: Stephane Chatigny @ 2006-05-02 20:33 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 4376 bytes --]

Hello, 

 

I use the MIT MPB package on a machine running guile 1.6 and
Debian-Linux 3.1r0a. Apparently, I generate a memory link while
executing a do loop (although I have not tracked the memory usage yet).
When I run the loop, the process is aborted before the end of the
iteration. Interestingly, the number of iteration is always the same for
a particular set of config parameters, but it will change if I change my
config parameters.

 

I have posted this question on the MPB mailing list but according to
Steven Johnson (the developer of the MIT MPB package) this bug is
probably related to Guile or Scheme and not to MPB. Here is a copy of
its post:

========================================================================
==========================================

I've noticed that if you perform large numbers of runs from within a
single .ctl file under Linux it sometimes eventually runs out of memory.


I haven't been able to find any memory leak in MPB, so my best guess is
that there is one in Guile.

 

A workaround is, when you have simple parameter-sweep loop, to put the
loop outside MPB (i.e. launch a new MPB process for each loop
iteration). 

e.g. in the bash shell under Linux, do:

 

            for x in `seq a dx b`; do program x=$x myfile.ctl; done

 

See also

 

 
http://ab-initio.mit.edu/wiki/index.php/Guile_and_Scheme_links

 

Cordially,

Steven G. Johnson

 

 

Does anyone know a solution to this problem? 

 

 

Here is a copy of my program (there is a couple of command for mpb...
the do loop is at the end):

 

Thanks

Stef

========================================================================
===================================================

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
;Based on an Example of Martin Lokke Nielson Thesis p143 
;TRIANGULAR Lattice of Air holes in silica 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 




(define bands 32);Number of bands calculated 

(define kzstart 0);z-component of the k vector 
(define kzstep 0.01);z-component step 
(define kzend 5);z-component of the k vector 

(set! tolerance 1e-4);Defines tolerance for convergence 
(set! mesh-size 3) 
(set-param! resolution 8) 
(define-param k-interp 0) 

(define rstart 0.2);start value of rod radius, r 
(define rstep 0.025);increase r of step size rstep 
(define rend 0.5);limit for non-overlapping cylinders 

(define nstart 1) ;start band 
(define nstep 1) 
(define nend (- bands 1)) ;end band 


(define estart (* 1.44402 1.44402)) ;start epsilon Silica @ 1550nm 
(define estep 1) ;epsilon steps 
(define eend (* 1.44402 1.44402)) ;end epsilon 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
;;Defining Super-cell parameters\\ 
;Corresponds to translational invariant lattice 
(define S 1) ;Supercell definition                      
(define points 32) 
(set! num-bands bands)  ;Number of calculated bands 
(set! grid-size (vector3 points points 1)) 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
;; Define lattice, the unit cell\\ 
(set! geometry-lattice (make lattice (size S S no-size) 
                       (basis1 (/ (sqrt 3) 2) 0.5) 
                       (basis2 (/ (sqrt 3) 2) -0.5) )) 
(define (LatticeAndkz kz) 
    (set! k-points (list (vector3 0 0 kz)  ; Gamma 
                     (vector3 0 0.5 kz)        ; M 
                     (vector3 (/ -3) (/ 3) kz) ; K 
                     (vector3 0 0 kz)))        ; Gamma 
    (set! k-points (interpolate k-interp k-points)) 
) 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
;; Create periodic structure\\ 
;Defining the function structure\\ 
;In defined unit cell 
;Create cylinder of radius r 
;Invariant in z-direction 
;Air has n=epsilon=1 
;Calculates the bands 
(define (structure r) 

    (set! geometry 
        (geometric-objects-lattice-duplicates 
            (list (make cylinder (center 0 0 0) (radius r) (height
infinity) 
(material air))))) 
     (run) 
) 



;Background medium is set 
(define (background-material e) 
    (define medium (make dielectric (epsilon e))) 
    (set! default-material medium) 
) 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
;;Loops which outputs epsilon, rod-radius and kz 
(do ((e estart ( + e estep))) ((> e eend)) 
    (background-material e) 
    (do ((r rstart ( + r rstep))) ((> r rend)) 
               
        (do ((kz kzstart ( + kz kzstep))) ((> kz kzend)) 
            (LatticeAndkz kz)    
               (structure r) 
         ) 
    ) 
)

 

 


[-- Attachment #1.2: Type: text/html, Size: 12483 bytes --]

[-- Attachment #2: Type: text/plain, Size: 140 bytes --]

_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: potential memory leak in do loop
  2006-05-02 20:33 potential memory leak in do loop Stephane Chatigny
@ 2006-05-03  1:48 ` Kevin Ryde
  2006-05-03 13:32   ` stephane chatigny
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Ryde @ 2006-05-03  1:48 UTC (permalink / raw)
  Cc: guile-user

Stephane Chatigny <Stephane.Chatigny@coractive.com> writes:
>
> (although I have not tracked the memory usage yet).

You'll probably have to use one of the various malloc debugging
packages to find who has allocated the memory that's never freed, to
see who's supposed to be responsible for that.


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: potential memory leak in do loop
  2006-05-03  1:48 ` Kevin Ryde
@ 2006-05-03 13:32   ` stephane chatigny
  2006-05-03 14:09     ` Paul Emsley
                       ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: stephane chatigny @ 2006-05-03 13:32 UTC (permalink / raw)


Thanks Kevin,

Does a Unix command like "pmap PID" could help me to determine if there
is a memory leak in the process?

I have run the program for 24hrs and the memory usage seems to be
constant at ~28-30Mb. It usually takes 36hrs to generate the bug, I will
wait and see if the memory usage remains constant.

regards
Stef




Kevin Ryde a écrit :
> Stephane Chatigny <Stephane.Chatigny@coractive.com> writes:
>> (although I have not tracked the memory usage yet).
> 
> You'll probably have to use one of the various malloc debugging
> packages to find who has allocated the memory that's never freed, to
> see who's supposed to be responsible for that.
> 
> 
> _______________________________________________
> Guile-user mailing list
> Guile-user@gnu.org
> http://lists.gnu.org/mailman/listinfo/guile-user
> 




_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: potential memory leak in do loop
  2006-05-03 13:32   ` stephane chatigny
@ 2006-05-03 14:09     ` Paul Emsley
  2006-05-03 22:47     ` Kevin Ryde
  2006-05-04 14:41     ` stephane chatigny
  2 siblings, 0 replies; 6+ messages in thread
From: Paul Emsley @ 2006-05-03 14:09 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=unknown-8bit, Size: 1036 bytes --]


I suspect you need valgrind.  valgrind rocks.

You will need the standard guile suppressions.

Paul.

On Wed, May 03, 2006 at 09:32:54AM -0400, stephane chatigny wrote:
> Thanks Kevin,
> 
> Does a Unix command like "pmap PID" could help me to determine if there
> is a memory leak in the process?
> 
> I have run the program for 24hrs and the memory usage seems to be
> constant at ~28-30Mb. It usually takes 36hrs to generate the bug, I will
> wait and see if the memory usage remains constant.
> 
> regards
> Stef
> 
> 
> Kevin Ryde a écrit :
> >Stephane Chatigny <Stephane.Chatigny@coractive.com> writes:
> >>(although I have not tracked the memory usage yet).
> >
> >You'll probably have to use one of the various malloc debugging
> >packages to find who has allocated the memory that's never freed, to
> >see who's supposed to be responsible for that.


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: potential memory leak in do loop
  2006-05-03 13:32   ` stephane chatigny
  2006-05-03 14:09     ` Paul Emsley
@ 2006-05-03 22:47     ` Kevin Ryde
  2006-05-04 14:41     ` stephane chatigny
  2 siblings, 0 replies; 6+ messages in thread
From: Kevin Ryde @ 2006-05-03 22:47 UTC (permalink / raw)
  Cc: guile-user

stephane chatigny <stephane.chatigny@coractive.com> writes:
>
> Does a Unix command like "pmap PID" could help me to determine if there
> is a memory leak in the process?

I suppose.  I only ever look at "top" to see if it's going up.


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: potential memory leak in do loop
  2006-05-03 13:32   ` stephane chatigny
  2006-05-03 14:09     ` Paul Emsley
  2006-05-03 22:47     ` Kevin Ryde
@ 2006-05-04 14:41     ` stephane chatigny
  2 siblings, 0 replies; 6+ messages in thread
From: stephane chatigny @ 2006-05-04 14:41 UTC (permalink / raw)


Thanks Kevin and Paul,

I am little bit rusty with Linux.  I have not used it since my graduate 
studies ten years ago. I was not aware of the "top" command. I will 
monitor the process with it. Right now the memory usage seems fairly 
constant at 30Mb.

If I need to use some kind of debuging package, I guess that I will need 
at least to recompile "mpb" with the proper debugging flag. That will 
help to see if the problems comes from mpb.

Do I have also to recompile "Guile" with the debuging flags on?


thanks
Stef





stephane chatigny a écrit :
> Thanks Kevin,
> 
> Does a Unix command like "pmap PID" could help me to determine if there
> is a memory leak in the process?
> 
> I have run the program for 24hrs and the memory usage seems to be
> constant at ~28-30Mb. It usually takes 36hrs to generate the bug, I will
> wait and see if the memory usage remains constant.
> 
> regards
> Stef
> 
> 
> 
> 
> Kevin Ryde a écrit :
>> Stephane Chatigny <Stephane.Chatigny@coractive.com> writes:
>>> (although I have not tracked the memory usage yet).
>>
>> You'll probably have to use one of the various malloc debugging
>> packages to find who has allocated the memory that's never freed, to
>> see who's supposed to be responsible for that.
>>
>>
>> _______________________________________________
>> Guile-user mailing list
>> Guile-user@gnu.org
>> http://lists.gnu.org/mailman/listinfo/guile-user
>>
> 
> 
> 
> 
> _______________________________________________
> Guile-user mailing list
> Guile-user@gnu.org
> http://lists.gnu.org/mailman/listinfo/guile-user
> 



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-05-04 14:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-02 20:33 potential memory leak in do loop Stephane Chatigny
2006-05-03  1:48 ` Kevin Ryde
2006-05-03 13:32   ` stephane chatigny
2006-05-03 14:09     ` Paul Emsley
2006-05-03 22:47     ` Kevin Ryde
2006-05-04 14:41     ` stephane chatigny

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).