Python hits the spot

John Hunter jdhunter at nitace.bsd.uchicago.edu
Sat Jun 22 13:32:05 EDT 2002


>>>>> "Siegfried" == Siegfried Gonzi <siegfried.gonzi at kfunigraz.ac.at> writes:


    Siegfried> Note: the first 20 minutes everything went on right
    Siegfried> (including the two external functions). On Windows
    Siegfried> after the first wavelength the system sucks down too,
    Siegfried> but it keeps up.

It is very difficult to test and debug code when your system freezes,
because it takes so long to reboot.  One trick I used when I was
encountering system freezes (ultimately it was a pointer problem) was
to set up an 'at' process to kill the job for me in case my system
froze.  Suppose your program is called 'myprog' and it takes roughly 5
minutes to get to the freeze point.  Try:

unix> at now +6min
at> killall myprog
at> CTRL-d                # Hit Control and D together
unix> ./myprog

With luck, the 'at' process will kill the job after 6 minutes and you
can try something else.  Much less painful than a reboot.

    Siegfried> I can send you the code (without) data, but that won't
    Siegfried> cure the situation.

Send it to the group.  Especially any C code involving memory
allocation and pointer dereferencing.  Before you start the 'myprog'
job, you may want to open a separate X term and run

unix> top

Then type 'M' to sort by memory usage.  Watch the % memory usage as
the program runs and see if it is increasing with time.  If it is, and
you aren't intentionally allocating increasing memory, then it is
likely that there is a free or delete statement somewhere in the C
code that runs fine that isn't being wrapped or called properly in the
python code.

JDH



More information about the Python-list mailing list