This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

strange heap error



>I wrote a program that does a Monte Carlo simulation of ferroelectric
>switching using the gsl scientific library (Because I needed a good random
>number generator).

Have you checked the number resulting from your random number calc. so that 
it is in range of, say, all arrays?

If you have some code like this (this isn't meant to compile or run as is):

#define NUM_ARRAY       8

int     iarray[NUM_ARRAY];

do {

n = (float) rand() / RAND_MAX * NUM_ARRAY;

printf("%d\n", iarray[n] );

} while (1);

there is 1 in RAND_MAX chance that an array access will be done outside the 
bounds of the array.  (The reason is that if rand() gives RAND_MAX,  rand() 
/ RAND_MAX * NUM_ARRAY  gives 8.  This is outside the range of the array 
0..7.)  This could take hours to happen.


>The simulation is actually performed on 8-10 computers
>simultaneously, each of which runs a client program that does the math. The
>results are collected then by a server program via TCP/IP over our LAN when

Are you sure the TCP/IP stack or buffer isn't running out of mem/heap space?


>the clients are finished. This works all flawlessly, when each client does
>its own independent simulation and returns the final results after 6 hours
>or so. However, I run into problems when each client is given basically the
>same task (just with a different random number seed) and the intermediate
>results are collected by the server every 5 minutes or so to calculate an
>average over all the results obtained from the clients to improve the
>statistics.

When all clients are doing the same calcs, you will end up with a different 
distribution of numbers that if they do a different set of calcs.  Perhaps 
the results when collected cause some sort of overflow?


>In this case the server program dies after 2 hours or something with :
>
>couldn't commit memory for cygwin heap, Win 32 error 487
>The computer running the server program, also runs one client, and a couple
>more programs to keep track of which clients are online and to maintain a
>log file of the simulation currently being executed. All these programs run
>in an independent cygwin bash shell.

Have you tried running the program without using the bash shell, from the 
command line?


>I would greatly appreciate some comments on the nature of this error, and
>what might be the possible cause and remedy for it. In case more details
>need to be provided, I'll be happy to do this.

I favour the distribution theory, followed by the bash shell taking up too 
much memory.  Please keep us informed if you find the problem.

-
Regards,
        Mike

I'm not addicted to the Internet.  I only use it once a day, and I can stop 
whenever I want.



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]