I'm using the Guichan lib and I was trying to run the "First application with Guichan, OpenGL and SDL" example, which is located here Click Here .

Everything was fine exept when I exit the program and delete all the pointers which were allocated with the "new" and because of this deletion I get an unhandled exeption/acces violation error. Note that I dont follow that example to the last line, but it should still be okay, I do the allocation in the constructor and deallocation in the destructor etc. I noticed that the same happens even if I run the example program to the last line.

Error: Click Here
(When I dont delete the pointers which were allocoted with "new", like its shown in the example, everything is just fine, not to mention the memory leak.)

Recommended Answers

All 3 Replies

My guess is that when the application adds the pointers to the top container, that it deletes them when finished, resulting in the access violation. You should probably run the application in the debugger so you can see if that is the case.

I downloaded the latest version of this lib and now I get some exeptions not at the dealocattion/deletion, but when trying to allocate some pointers with "new". I get the "bad memory alloc".

Here's what I mean: Click Here

Different example I'm following: Click Here

I have stuble upon that error myself, and in some cases, it was due to some pointer arithmetic which turned out to point to the 0x0 address.
Either you did something, and changed the address of some variable to the 0, meaning the null one, or it's something else. But when the error sais that it's an access violation, that means that one of your pointers is trying to access a block of memory which is located at 0x0.
What to do may be your next question.
Use the debug off the Visual c++, trace back the error to the source, try to figure out what could cause that access violation, and than fix the problem.
If you do have further questions, post them here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.