Skip to main content
gamedev.net
🔒 Locked

Common Acess Violation Error

Started by kag1 Jan 9, 2005 at 5:15 PM 2 replies 900+ views
Original Post
kag1
kag1
I seem to get this error all the time...Acess Violation reading ____. Im wondering what causes this error to occur. It often is me trying to use a pointer to something before initializing it. Sometimes setting the pointer to NULL before using it works..and sometimes actually doing the

Pointer = new Pointer(var1)
I'm just curious what I can do to make sure I don't get these kindof errors anymore..and what they are caused by..(I think it's using pointer before initializing them...but I don't know for sure) thanks alot
nmi
nmi
When freeing memory, do you set your pointer back to NULL ?
kag1
kag1
no..i havn't been
nmi
nmi
So you should try replacing

free(p);

by

free(p);
p = NULL;

Same for delete and delete[].

If the access violation then is when accessing address 0 (or close to it), then you probably have used pointers after freeing the memory.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.