Dear Gambitizers,
I have programmed a simulation, and the list has successfully helped me with a few prior problems. Those are taken care of, but now I have a much more basic problem: I'm using up memory, to the point where my kernel (named after a certain Finn)
# uname -srmp Linux 2.6.26-custom i686 Intel(R) Core(TM)2 Quad CPU Q6700 @ 2.66GHz
kills the program. Of course I had the common misconception that this would never happen in a Lisp-like language and on and on: my real concern is that there is some basic programming technique that I am missing. Basically, is something failing to get garbage-collected?
I will discuss a specific problem below, but I ask the kind generosity of someone who could examine the code (or show me how to better examine it), and let me know if there are any major red-flags, or ways I could improve it.
My basic goal is that since I really enjoy programming in Scheme, I'd like to avoid having to do this in FORTRAN on the big ol' supercomputer here. Yes, I am in school, but my adviser had never heard of Scheme before I mentioned it to her ;)
To stop the memory allocation problem, I attempted to install an exception handler:
(define (mem-handler exc) (if (or (heap-overflow-exception? exc) (stack-overflow-exception? exc)) (if (noncontinuable-exception? exc) (abort exc) exc) (with-exception-catcher error-handler (lambda () (raise exc)))))
And then run the main driving routine within this like so:
(with-exception-handler mem-handler (lambda () (gen-sim-data)))
Here's what happens when I run it:
chondestes: /home/joel/lisp/scm/agjones> nice -n +10 jonesim -:m1000000,dR- *** WARNING -- Variable "gsl-vector" used in module "genxic.o1" is undefined .9999107177669622 2000 50 16 2 1000. .5 0. 0. 0. 1e-4 1. .25 true .9999111243206196 2000 50 16 2 1000. .5 0. 0. 0. 1e-4 1. .25 false .9999110166041458 2000 50 16 2 1000. .5 0. 0. 0. 1e-4 1. .75 true .9999111775781226 2000 50 16 2 1000. .5 0. 0. 0. 1e-4 1. .75 false .9999108917731552 2000 50 16 2 1000. .5 0. 0. 0. .09 1. .25 true .9999104499002971 2000 50 16 2 1000. .5 0. 0. 0. .09 1. .25 false .9999107898981544 2000 50 16 2 1000. .5 0. 0. 0. .09 1. .75 true zsh: killed nice -n +10 jonesim -:m1000000,dR-
Thanks for any help you can offer,
Joel
Getting the code ================
The code is available for public download from svn at
http://chondestes.bio.unc.edu/svn/models/agjones
A simple "make" in the top directory will yield a single executable that reads "input.txt." The critical parameter is "N," the first variable in "input.txt." I have tested this at 10, 100, and 2000, and it only finishes successfully at N=10.
To run it you will need the loadable library "genxic.o1" from the package located at
http://chondestes.bio.unc.edu/svn/genxic/trunk
To build the library, do a "make" in the scm/ directory, then copy it to the top directory of agjones/.