I assume that you really do mean "i++" down there.

It's hard to say whether it's a memory error without having some idea what
the value of NUM_WALLS is.  However, as a general rule, anytime you are
performing an operation that involves memory allocation, you should check to
be sure that it worked properly.

So, try putting all of that code in a try block and seeing what comes of it.
I looked at <vector> and it has some pretty disturbing behavior when
exceptions are turned off.  (It calls abort() from time to time, but what
else can it do?)  So, you should probably have them turned on anyway.

Good luck.

George


----------
>From: David Korus <[EMAIL PROTECTED]>
>To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
>Subject: Strange Vector Error
>Date: Wed, Oct 13, 1999, 14:15
>

>
> Hi all,
>  I'm having a strange crash using STL vectors.  Maybe one of you has
> some idea what it is.  Note, I'm using the Metrowerks version 6 beta (the
> vectors seem to work a lot better under this version).  Here is what's
> happening:
>
>  1)  I do some initialization which consists of setting array values
> and more importantly, pushing some integers onto an integer vector.
>  2)  Next I do some processing.  This creates some vectors, does some
> various operations, and returns.
>  3)  Lastly I do the initialization sequence again which seems to
> crash during one of the "push_back" operations on the integer vector.
> Something like this:
>  
>  newwallsy.clear();
>  for(i=0;i<NUM_WALLS;i+)
>  {
>       newwallsy.push_back(0);
>  }
>
> where newwallsy is defined as
>  vector <int> newwallsy;
>  and NUM_WALLS is some defined integer value
>
> On the palm, this comes up as a fatal error (the one that displays the reset
> button and freezes the palm) and on the emulator it simply gives a
> "gremlins" error (an error box that just says "gremlins".
>
> Anyway, since this only crashes the second time I call the routine, I
> suspect that I'm running out of memory.  Does this sound consistent?
>
> I suppose what I'm looking for is:
>
> 1)  does this look like an out of memory error?
> 2)  If so, how can I check my free memory to see how much I have?
> (right now I'm trying MemHeapFreeBytes, but I'm not sure I'm using it
> correctly)
> 3)  If not, does anyone have any ideas what the problem might be?
>
>
> David Korus
> Blevins Enterprises Inc.

Reply via email to