PDA

View Full Version : Access Violation Error (can't find the cause).



Chesso
09-01-2007, 09:45 AM
In my game, I have blocks setup as being breakable or just normal.

Depending on which ones I make breakable, when finishing the level and trying to free the stuff up, I get an access violation error on the first breakable object it tries to free (but the error seems to happen before I even check if the object is dead or try anything on it).

I tested by sticking a ShowMessage in there to see where exactly it fuddles up, but it never shows, it only shows the error (this is in a for loop).

Is there any good methods of narrowing this down and finding out what on earth is going on?

Considering if I change which ones are breakable, it will work with some configuration but not others, it's a tad confusing.

jasonf
09-01-2007, 09:47 AM
does it error on the first breakable object.. or the first breakable object that has been broken?

Are you freeing up objects as you go and then attempting to free them again at the end?

Chesso
09-01-2007, 10:25 AM
The first, newly defined breakable object.

I swapped some non breakable objects, to breakable objects.

I make them .Dead when collisioned but I check if they are dead or not when I free stuff up before Calling Dead and Free (although calling one or the other makes no difference, the error remains).

Paizo
09-01-2007, 10:40 AM
some code should be helpfull.
i got this kind of error usually when i load images 'on the fly', anyway is related to wrong memory access, check if you attempt to write in a nil variable

Chesso
09-01-2007, 10:40 AM
Ok, I have been looking at the sprite engine and it appears if I call this:

DXSpriteEngine.Engine.Clear;

Then I don't even have to write any other code at all and it will handle it for me and it avoids the error (most importantly) lol.

But just to confirm, does anyone know if this really dead and free's them all up? (e.g. anything in the spriteengine that isn't already dead and free'd).