Jump to content
  • Advertisement
Sign in to follow this  
blaze02

memory leak somewhere

This topic is 4518 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Running my prog in debug mode works fine without error or warning. When I run the program in release, however, this msg comes up. It appears right after the client connects to another client. First-chance exception at 0x71a92413 in Shooter.exe: 0xC0000005: Access violation writing location 0x00130000. First-chance exception at 0x00409869 in Shooter.exe: 0xC0000005: Access violation reading location 0x00000002. Then it repeats this until the program is exited: First-chance exception at 0x00000000 in Shooter.exe: 0xC0000005: Access violation reading location 0x00000000. The memory leak is getting detected, but its not giving me any indication as to where it is. I know there are libraries in the compiler that may be able to help me, can anybody point me towards those functions? When it attempts to read from location 0x00000002, I'm assuming that is my structure with 2 shorts; pretty much the only time I'm reading from a memory address that is not divisible by 4. Any suggestions? Why would running debug mode not detect this memory leak?

Share this post


Link to post
Share on other sites
Advertisement
The typical problem when switching from Debug to Release is that variables don't automatically get initialised to zero in release.

Check for this. Hope that helps,

Dave

Share this post


Link to post
Share on other sites
I always have compiler warnings on the highest level. It will warn if there is a chance something is not initialized before use, plus there are run-time checks to make sure variables are getting set before they are used.

Share this post


Link to post
Share on other sites
Turn "Generate Debug Info" on for your release build. This will help give you more useful info in the debugger when it does in fact crash.

Share this post


Link to post
Share on other sites
Quote:
Original post by davidlkoenig
Turn "Generate Debug Info" on for your release build. This will help give you more useful info in the debugger when it does in fact crash.


It was on, thats why it was generating the errors in the first place.

Share this post


Link to post
Share on other sites
BTW, these are not memory leaks. A memory leak happens when you are unable to deallocate (and reuse) memory, usually because the pointer to the allocation is overwritten. Here is a simple example of a memory leak:
    int * pAlloc = new int[ 1048576 ]; // A 4MB allocation
pAlloc = &some_other_int; // The allocation is now "leaked"

// At this point, the address of the allocation is lost, and so the memory can
// never be deallocated and reused.
The problem you are having is dereferencing an invalid pointer. The usual reasons are:
  • referencing deallocated memory,
  • dereferencing an uninitialized pointer,
  • bad pointer arithmetic,
  • dereferencing a pointer that has been set to 0 (to indicate that the memory was deallocated),
  • dereferencing a pointer parameter whose value is 0, and
  • this == 0.

Share this post


Link to post
Share on other sites
Quote:
Original post by ussnewjersey4
Try using the Fluid Studios memory manager. It can detect memory leaks and keeps track of all memory allocations, and it may be able to detect your memory problems. Its also extremly easy to use: just include the headers.
Fluid Studios Memory Manager


I'm looking into that now. I don't see it helping me much because I don't create memory dynamically too often. And I don't use _alloca() anymore. I'm assuming my problem is some bad ptr math, but I don't see where, and I don't see why it wouldn't cause a problem in debug mode.

Yeah, I know it is not exactly a leak. Its most likely me derefencing null memory somehow.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!