Author Topic: league out of memory error  (Read 10059 times)

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
league out of memory error
« Reply #15 on: December 24, 2006, 11:29:50 PM »
I still use the wiki from time to time to look up things about the DNA.  I definately think a wiki works best as a way to post the final summary of a long discussion instead of as an avenue for discussion.  Forums are very much the other way around.

League code is messy, and it's my fault, and I take full responsibility   It was the first really major enhancement I made to the source code.  Thankfully I've learned alot about software engineering in the interem.

A little off topic, but one of the reasons I like C# so much is that it makes error handling alot nicer.  You can post the call stack for a bug right in the error message.  I could never figure out how to do that in VB, C++, or any other languages I've programmed in.

Offline Jez

  • Bot Overlord
  • ****
  • Posts: 788
    • View Profile
league out of memory error
« Reply #16 on: December 25, 2006, 06:22:41 AM »
Quote from: Numsgil
I still use the wiki from time to time to look up things about the DNA.  I definately think a wiki works best as a way to post the final summary of a long discussion instead of as an avenue for discussion.  Forums are very much the other way around.

That's how I use the Wiki as well. I have never used it for discussion and only edited it, usually following questions in the forum, when there was a definitive piece of text I could add. (plus a couple of errors I corrected in the writing 1G bots bit when I was writing a 1G bot). Part of the problem, for me, is that I only surf the wiki when I am looking for a bit of information that I know should be there.
I guess it is the best source for newbies to the game to use, it is clearer and easier to locate info there than here on the forum.

I personally would much prefer if you started a couple of topics in the forum to use as a discussion base, I can link them from the existing, relevant, stickies or make them into stickies in their own right if you prefer.

PY, btw, used to get paid to play with DB because he was so efficient at doing his job and had lots of free time, unfortunately, I think they spotted how good he was and have given him lots of other things to do. I'm sure if he ever gets enough free time again he will return.

Quote
League code is messy, and it's my fault, and I take full responsibility   It was the first really major enhancement I made to the source code.  Thankfully I've learned alot about software engineering in the interem.
Code: [Select]
  'this little snippet insures that Numsgil can run his code alright
  If Left(MDIForm1.MainDir, 15) = "C:\darwinsource" Then _
    MDIForm1.MainDir = "C:\DarwinbotsII"
    
  ' Here's another hack like the above so that EricL can run in VB
  If Left(MDIForm1.MainDir, 51) = "C:\Documents and Settings\Eric\Desktop\DB VB Source" Then _
    MDIForm1.MainDir = "C:\Program Files\DarwinBotsII"
Just made me laugh.  


Plus a little snippet of code I presume is relevant to leagues for Griz (removed as already in wiki)

You missed a chance to tell me what the immediate window does btw Nums' I'm gonna be forced to find out for myself soon.

Edit

Nice work Griz, I've just been browsing the wiki links you gave and noticed you have already started updating.  
« Last Edit: December 25, 2006, 06:47:27 AM by Jez »
If you try and take a cat apart to see how it works, the first thing you have in your hands is a non-working cat.
Douglas Adams

Offline Griz

  • Bot Overlord
  • ****
  • Posts: 608
    • View Profile
league out of memory error
« Reply #17 on: December 25, 2006, 12:39:50 PM »
Jez ...
left you some messages at http://www.darwinbots.com/WikiManual/index...e=User_talk:Jez
you should be alerted as to any new messages there when you log in ...
but just in case ... now you know.
不知
~griz~
[/color]
   "The selection of Random Numbers is too important to be left to Chance"
The Mooj  a friend to all humanity
[/color]

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
league out of memory error
« Reply #18 on: December 25, 2006, 03:46:24 PM »
Some quick responses:

You can make *some* changes to the source code while DB is running, but you have to pause VB first, either with the pause button or by hitting a breakpoint.  What changes you are able to make may not make sense without a programming background, but basically, while paused, you can change or add things to the source code as long as it doesn't mess up the VB interpreter's state.  It will tell you if it it does.  You can generally do all sort of things to routines that arn't on the call stack, but only certain things to routines that are.  You can't declare a new variable for example in a routine on the stack without halting the program's exectuion in VB but you can make other changes, add lines, new routines, etc..

The immediate window is a mostly a place where you can execute code you write on the fly while debugging - code that is not part of the program, but code you want to execte right then for help in debugging.  Say you hit a breakpoint and want to step through from there, but with a certain set of variables having a certain set of values, say to reproduce a bug further down the line.  Well, instead of waiting for the program to happen upon those values, you can change those varaible values manually in the immediate window e.g. x = 5, y = 10, etc. and then proceed.  The code you type in the immediate window is, well, immediate.  It does not become part of the DB source code - it only executes right there and then is gone.  Also useful for things like printing variable values at breakpoints.

I agree with the discussion of wiki v.s forum.  Wiki is for static, long lived information.  Forum is for dynamic discussion.

Most of the league code is in the F1mode module though some is in with the options form code and a few other places.

Any assistance that helps narrow down a bug is totally appreciated.  The ones with the long repro times are the worst.  If someone catches one of these in the debugger, that is gold since they are so hard and time intensive to reproduce.  Even just telling me what line it occurs on and nothing else helps tremendously.  Non-programmers who are willing to run under VB can really be tremendously helpful even without any understanding of the source code or programming skills.  Some bugs can be environment specific and hard to reproduce execpt on a specific machine.  Getting someone to run DB under VB on that machine can be serious money and save days of debugging elsewhere.  Many thanks!
Many beers....

Offline Jez

  • Bot Overlord
  • ****
  • Posts: 788
    • View Profile
league out of memory error
« Reply #19 on: December 25, 2006, 05:00:15 PM »
Thanks for the head up Griz, I wouldn't have seen that for a while if you hadn't mentioned it. Will check it after this post.

Also thanks for the reply Eric, I have located the pause button (VB newbs   ) edited the code as per the location Griz identified and restarted the sim. Hope it didn't need to be saved first. Also hope that is the only line of the code I had to amend.

I am so much more in awe of the work you have done Eric/PY/Nums, having run the sim in VB debugger now, the last league match round took over 8hrs to finish. It is a time waste and a half X10 tracking these niggling little bugs down.

I think I have identified what you mean by 'breakpoint'; Run/break I guess. Still not sure how it would be used. (I surfed the VBv4.0 book and missed any info on using it  ) I don't think I am par for the course when it comes to using the immediate window yet.

Your thanks are appreciated, (new leaue: bug spotting  ) but should I be able to email you a bottle of your favourite tipple (it is xmas) then I would. Plus a bottle to all the others that have contributed to the creation and evolution of DB!  
If you try and take a cat apart to see how it works, the first thing you have in your hands is a non-working cat.
Douglas Adams

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
league out of memory error
« Reply #20 on: December 25, 2006, 05:29:36 PM »
The two lines I was referring to where exception handling should commented out when running in the debugger are the first list of simload() in MDIForm1.frm and the 6th line of main() in main.frm.  Both lines can be found by searching (Ctlf+F) for the string 'error.sim' and have the form On Error Goto...

You don't need to save before running - your changes will be picked up and respected by the interpreter - but they will be lost if the power goes out or VB itself crashes (happens sometimes).

A breakpoint is simply a place - a specific program line - or certain condition under which you want exectuion to stop.  Put the cursor on a line in the source and hit F9.  Presto, instant breakpoint.  It can be as simple that, which is basically stop here if you ever get to this line" or as complicated as a watch expression e.g. "stop wherever you are if this variable or complicated expression ever has this specific value".  Happy debugmas!
Many beers....

Offline Jez

  • Bot Overlord
  • ****
  • Posts: 788
    • View Profile
league out of memory error
« Reply #21 on: December 25, 2006, 06:07:17 PM »
Quote
the 6th line of main() in main.frm

Can't find that .frm, search also only gave me the one reply.

have ' the one line in;
'On Error GoTo fine ' Uncomment this line in the compiled version error.sim
  If path = "" Then
    optionsform.Visible = False
    CommonDialog1.DialogTitle = MBLoadSim

That is all I had to do I hope, not ' the subset.

I reckon another few days before  I hit the overlow bug so no rush

Here's hoping my chipset fan, which resisted both the vacuum cleaner and cotten buds before a good puff sorted it, holds out a little longer...
(/me listens for nasty girinding soundings that preceeded last two graphics crashes)
« Last Edit: December 25, 2006, 06:17:32 PM by Jez »
If you try and take a cat apart to see how it works, the first thing you have in your hands is a non-working cat.
Douglas Adams

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
league out of memory error
« Reply #22 on: December 25, 2006, 06:27:52 PM »
Quote from: Jez
Can't find that .frm, search also only gave me the one reply.
Also called Form1


Quote from: Jez
have ' the one line in;
'On Error GoTo fine ' Uncomment this line in the compiled version error.sim
  If path = "" Then
    optionsform.Visible = False
    CommonDialog1.DialogTitle = MBLoadSim

That is all I had to do I hope, not ' the subset.
That's it.
Many beers....

Offline Griz

  • Bot Overlord
  • ****
  • Posts: 608
    • View Profile
league out of memory error
« Reply #23 on: December 25, 2006, 06:31:18 PM »
Quote
The immediate window is a mostly a place where you can execute code you write on the fly while debugging - code that is not part of the program, but code you want to execte right then for help in debugging.  Say you hit a breakpoint and want to step through from there, but with a certain set of variables having a certain set of values, say to reproduce a bug further down the line.  Well, instead of waiting for the program to happen upon those values, you can change those varaible values manually in the immediate window e.g. x = 5, y = 10, etc. and then proceed.  The code you type in the immediate window is, well, immediate.  It does not become part of the DB source code - it only executes right there and then is gone.  Also useful for things like printing variable values at breakpoints.

good to know. thanks. I'll try to put this all into a Debugging Guide ...
so any other hints/techniques you can share will be appreciated.
you just got to put them somewhere where I can find and gather them.
hmmmm ... I know of such a place.

Quote
Wiki is for static, long lived information.  Forum is for dynamic discussion.
that sounds like a pretty good guideline. however, finding things here on the forum
still leaves something to be desired ...
esp if one, such as a newbie, doesn't already know it exists.
I still have a hard time tracking down messages/topics I KNOW are here somewhere ...
they tend to end up being scattered about in different threads ...
and even then have spent a great deal of time searching for them, sometime unsuccessfully.
so I'm still for making it as easy as possible for those folks who haven't been in on all the
discussions from the beginning, to be able to find their way around ...
and hopefully have them aware that there is also such a thing as the wiki available to them.
some may find it easier and less confusing to work there. I certainly do.
at least the search function here seems to now at least sorta work.
there is a search function on the wiki as well.
 
Quote
Most of the league code is in the F1mode module though some is in with the options form
code and a few other places.
ok. thanks. I'll keep looking.

Quote
Any assistance that helps narrow down a bug is totally appreciated.  The ones with the long repro times are the worst.  If someone catches one of these in the debugger, that is gold since they are so hard and time intensive to reproduce.  Even just telling me what line it occurs on and nothing else helps tremendously.  Non-programmers who are willing to run under VB can really be tremendously helpful even without any understanding of the source code or programming skills.  Some bugs can be environment specific and hard to reproduce execpt on a specific machine.  Getting someone to run DB under VB on that machine can be serious money and save days of debugging elsewhere.  Many thanks!

for those running/searching for those errors in long sims ...
if you run the compiled version and do an occasional save ...
[this can be automatically done, yes?]
then hopefully when an error is encountered and an error.sim
file produced ...
you can then fire it up in VB, ensuring the error trapping is
commented out, load in the error sim or ideally, the save that
you captured which occurred just prior to the error ...
and then run it from there using the debugger.
this may not always work, as there seem to be many varialbles ...
but I have had it do exactly this for me in the past ...
even using the generated error.sim ...
the error still existing ...
which can certainly save a great deal of time debugging.
[remember to save/rename the error.sim to keep on file
for continued debugging, so it isn't overwritten]

onward
不知
~griz~
[/color]
   "The selection of Random Numbers is too important to be left to Chance"
The Mooj  a friend to all humanity
[/color]

Offline Jez

  • Bot Overlord
  • ****
  • Posts: 788
    • View Profile
league out of memory error
« Reply #24 on: December 26, 2006, 05:39:32 AM »
Quote
finding things here on the forum
still leaves something to be desired ...

As would finding things on wiki if we moved the discussions over there. It is the act not the arena that causes the chaos!

EDIT

Oh well, I have managed to get an error of sorts, I got fed up with 12 hour long rounds and used the win button, it didn't like that and after declaring one of the bots as winner the competitors disappeared and I am left with just veg.  
Nm, I needed to turn pc off today so I could get at its innards. Will restart this later.
« Last Edit: December 26, 2006, 06:39:08 AM by Jez »
If you try and take a cat apart to see how it works, the first thing you have in your hands is a non-working cat.
Douglas Adams

Offline Jez

  • Bot Overlord
  • ****
  • Posts: 788
    • View Profile
league out of memory error
« Reply #25 on: December 26, 2006, 07:26:03 AM »
Stopped DB via VB and restarted, tried to rerun league again, it asked where file \ was so I cancelled it, got run time error 75 Path/File access error - Caused by me not adding veg to (empty) bot list before I started league I think

DNATokenizing (Code)

  ->    FileCopy path2, path
    End If
    path = path2
    GoTo inizio
« Last Edit: December 26, 2006, 07:28:18 AM by Jez »
If you try and take a cat apart to see how it works, the first thing you have in your hands is a non-working cat.
Douglas Adams

Offline Griz

  • Bot Overlord
  • ****
  • Posts: 608
    • View Profile
league out of memory error
« Reply #26 on: December 26, 2006, 11:17:22 AM »
Quote from: Jez
Here's one I caught though, error 76 subscripts out of range IIRC

Was just rerunning the league and clicking the win button to see how easy it was to get the competitors to disapear again

HDRoutines (Code)

-> Open path For Binary As 1

    Put #1, , numOfExistingBots
   
    For t = 1 To MaxRobs
      If rob(t).exist Then

Debug even offers me breakpoints now, solves that issue.

error sim attached although I doubt it's of any use
this is where 'hovering' the mouse over the variables
to see their values can show you one that is out of range.
iow ... numOfExistingBots or MaxRobs or rob(t).exist or even 't'.
if you also report these values, that can help Eric or someone
familiar with what the ranges of the variable should be ...
to see if there is a problem with one of them.

also ... if you zip the error.sim first ... it will only be a few KB ...
much less than the 500+kb you've attached.
that makes it easier to download for me ...
using my *TCAAS isp
[*two-cans-and-a-string which at times is 28kbbs!!!
one, of only a couple, downside to living in the boonies.  ]

will load in your error.sim and poke around a bit.
don't hold your breath.
不知
~griz~
[/color]
   "The selection of Random Numbers is too important to be left to Chance"
The Mooj  a friend to all humanity
[/color]

Offline Jez

  • Bot Overlord
  • ****
  • Posts: 788
    • View Profile
league out of memory error
« Reply #27 on: December 26, 2006, 12:27:53 PM »
File zipped, sry didn't think about it.

You'd probably have better luck just re-running the league under debugger and clicking win repeatedly, error sims for leagues don't hold the relevant league info. Only took me a couple of minutes to reproduce. you may notice, specially if you start clicking as soon as the sim starts, the number of wins going up by two for every click.

Anyway, am having go at hovering mouse stunt:

t = 0


    Put #1, , Len(SimOpts.AutoRobPath) =""
    Put #1, , SimOpts.AutoRobPath =""
    Put #1, , SimOpts.AutoRobTime =0
    Put #1, , Len(SimOpts.AutoSimPath) =""
    Put #1, , SimOpts.AutoSimPath =""
    Put #1, , SimOpts.AutoSimTime =0
    Put #1, , SimOpts.BlockedVegs =FALSE
    Put #1, , SimOpts.Costs(SHOTCOST) =23
    Put #1, , SimOpts.CostExecCond =0.004

Hmm, there are lots of these, oops, it didn't want to give me these at first but I think these are the ones you were talking about:  

Num of existing bots =15
MaxRobs  =16

How do you decide what is relevant? Is it just the next few values after highlighted line?
If you try and take a cat apart to see how it works, the first thing you have in your hands is a non-working cat.
Douglas Adams

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
league out of memory error
« Reply #28 on: December 26, 2006, 12:56:10 PM »
Quote from: Jez
How do you decide what is relevant? Is it just the next few values after highlighted line?
This is where knowing the code and having some programming background starts to be important.  Bascially, VB will detect an exception on a specific line.  That is, something "illegal" is happenign on that line as far as VB is concerned such as an attempt to devide by 0 or in this case, an attempt to reference an array element outside the bounds of the declared arrray size.  If you report the values of the variables on the line in which VB indicates there is a problem, that should be sufficient.  I will also point out that a set of repro steps as you indicate above (e.g. pressing win a ton of times, etc. ) is just as good or better casue it lets me quickly reproduce the problem in the debugger on my machine where I can explore the root cause of the problem interactivly.  A lot of the time, the root cause isn't where the "illegal" operation is being attempted.  Its way back down the line.  

I will look at this as soon as I can.  Right now, I'm still trying to catch that memory leak...
Many beers....

Offline Griz

  • Bot Overlord
  • ****
  • Posts: 608
    • View Profile
league out of memory error
« Reply #29 on: December 26, 2006, 01:01:07 PM »
Quote
You'd probably have better luck just re-running the league under debugger and clicking win repeatedly, error sims for leagues don't hold the relevant league info. Only took me a couple of minutes to reproduce. you may notice, specially if you start clicking as soon as the sim starts, the number of wins going up by two for every click.
I had noticed in the past that unless one is VERY quick on clicking ... it jumps up by 2 or 3 wins. need a bit of delay built in there somewhere, eh?

Quote
How do you decide what is relevant? Is it just the next few values after highlighted line?
well, IN the line the debug brought you to, eh? the error occurred/was found ... there, yes?
if the problem can be seen there ...
then troubleshooting is about going back 'upstream' to see where it may have come from ...
but that quickly gets into PY/Num/Eric territory, eh?
seeing/knowing what is out of place, is not quite right , is too ...
but sometimes it might be obvious.
ie ... if  'Num of existing bots' is greater than 'MaxRobs' ...  
or if in a 'from t = 1 to 10 loop, you see t is 0 or 11 ... that might be a hint.
or if a variable is >32768 ... and is defined as a single integer ... than there is a problem.
those are really the only one's I've spotted in the past ... only the most obvious.

but reporting these values for the variables in the offending line ...
is all good data for those who have a chance of knowing what it might mean.

this is the value of having a discussion and/or page on Debugging ...
where those with knowledge/experience can help those of us who do
not yet possess those skills but who are willing to learn ... do so ...
so we can then return the favor and help out on some level.
you know ... make it a real cooperative effort ...
sharing as much info as possible.

in fact ... that might be a good idea ...
to have a thread here just on Debugging ...
which I will also then mirror on the wiki ...
archiving the relevant info.
« Last Edit: December 26, 2006, 01:06:30 PM by Griz »
不知
~griz~
[/color]
   "The selection of Random Numbers is too important to be left to Chance"
The Mooj  a friend to all humanity
[/color]