weird error... can you help?

Sharky Forums


Results 1 to 4 of 4

Thread: weird error... can you help?

  1. #1
    Catfish
    Join Date
    Oct 2000
    Posts
    131

    weird error... can you help?

    Hi,

    I'm having some very frustrating trouble debugging a program i'm writing for class. The program creates and deletes numerous pointers to objects while testing itself. After a while, it will get to a constructor and, as I step through that instruction, the program crashes with the following dialog box (i'm using Visual Studio .Net):


    Unhandled exception at 0x77f7f570 in bufmgr.exe: User breakpoint

    The debug output similarly says:

    HEAP[bufmgr.exe]: Heap block at 00322980 modified at 003248F0 past requested
    size of 1f68
    Unhandled exception at 0x77f7f570 in bufmgr.exe: User breakpoint.

    where bufmgr.exe is the program that i'm writing. Does anyone know what this error means, and more importantly how i can fix it? I've never encounted anything like this before, and i'm totally stumped. I've been over my code many times, checked to make sure i delete objects when i don't need them, set deleted pointers to NULL and all of that fun stuff, but to no avail.

    thanks very much for any advice!
    -Evan

  2. #2
    Tiger Shark
    Join Date
    Feb 2001
    Location
    Satan Country
    Posts
    564
    I don't do windows, but it sounds like a protection fault error - you are probably doing something with some memory you are not supposed to be doing.

    Step through the program and find exactly where it is crashing out - youa re probably dereferencing something you should not be, or perhaps did not initalize a pointer properly before using it.
    I'm half Scottish and half French.

    I surrender to alcohol.

  3. #3
    Catfish
    Join Date
    Oct 2000
    Posts
    131
    Yes, i stepped through it, and it crashes when creating a new Page object (which i've defined, which just contains an array of bytes, with and empty constructor and destructor). However, it has crashed when creating other types of objects as well.

    So i might say:

    Page *p = new Page();

    and it crashes. This is why i'm so confused, because why would creating an object on the free store cause a failure in the debug heap? Doesn't make sense to me....

    -ev

  4. #4
    Tiger Shark
    Join Date
    Feb 2001
    Location
    Satan Country
    Posts
    564
    Ok, this makes a little more sense now....

    Your heap is where your new objects will be created, and somehow your heap size is set too small. I hope this does not sound insulting, if you know this already, but I want to make sure this is clear.

    It used to be the case that you would set a model for your program which dictated the size of your program, which would default to 64k, many years ago.

    I am not sure how to specify the heap size in windows, but you are apparently overrunning the maximum/ using too much memory.

    Try to keep a running total every time you create an object. Increment a counter with sizeof(obj) every time you use the new keyword, and keep track - you may be doing some massive allocation in a loop you did not realize was happening, and it could also be a result of allocations occurring in your constructors that you did not look at carefully, so keep that in mind.

    For a program to be absolutely correct, every object should have code which handles an out of memory exception. You can create that in a seperate class, with some effort, and use inheritance/multiple inheritance to mix it in to your objects, though this might be too much for what you are doing, it is something to keep in mind.

    I hope that this helps.
    I'm half Scottish and half French.

    I surrender to alcohol.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •