Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a maximum number of calculations that can be performed by a program before it stops working?
    primarykey
    data
    text
    <p>My apologies for the general nature of this question, but I cannot think of a good way to word it... Put simply, I'm a beginner that's written a program (in C, using CodeBlocks-EP) that performs a very large number of calculations (for simplicity, I've replaced the real (very useful) code with a pointless loop that also has a large number of calculations!).</p> <pre><code> int x, i; for (i=0; i&lt;9999999999999999; i++){ x=x+1; x=x-1; //real code is much more useful but spans 3000 lines! } printf("x is %i", x); //useful output </code></pre> <p>As I said, it works fine, and gives useful output. However, recently, I tried to make it run once for every day of a virtual year, rather than for just one day, like the following:</p> <pre><code> int x, i, day; for (day=0; day&lt;365; day++){ for (i=0; i&lt;9999999999999999; i++){ x=x+1; x=x-1; //real code is much more useful but spans 3000 lines! } } printf("x is %i", x); //useful output </code></pre> <p>and I received the following message before I get useful output:</p> <p><strong>My_program</strong>.exe has stopped working. A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available. Process terminated with status -1073741510 (24 seconds).</p> <p>On further inspection, it stopped working around day 60. HOWEVER (and here's the weird part...), the program works if you choose a smaller period, e.g. for days 0-60, OR days 30-71, or days 60-101 (so it is NOT breaking because of a programming issue with day 61).</p> <p>If I try to do more than around 60 days though (even days 0-70), it breaks after about 60 days. I can't think of anything wrong other than the fact that it is breaking due to "too many calculations"... But I've never heard of that problem. I'm a bit of a newbie, so any advice would be greatly appreciated here!</p> <p>I appreciate that it is unhelpful to not have the actual code, but at 3000 lines, it seemed sensible to replace it with something simpler! But I can confirm that it works for each individual day of the year, when ran as separate individual days... Just not as a block! If I can help by providing any other information, please let me know.</p> <p>Many thanks,</p> <p>Matt</p> <p>Update (23:21 26/12/2013): Thanks a lot for all the responses- turned out it was a memory leak and I'd missed a line of code resetting one of the counters, which in turn tried to then make a giant matrix... Sorry for being a noob and not knowing how to diagnose it, but I feel like I've learned something; thanks for the help!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload