CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 24 of 24
  1. #16
    Join Date
    Sep 2010
    Posts
    13

    Re: C++ Unhandled exception error

    Quote Originally Posted by Paul McKenzie View Post
    Nowhere do you mention use of a debugger. Are you using one?
    You can't write programs if you're not prepared to debug them on your own. It sounds like you took some code, compiled it, and hoped for the best, and if something goes wrong, throw together arbitrary bits of code to see if the problem goes away.

    Instead, you should have prepared for the inevitable step of having to debug the program at some point, whether that point is now or in the future.
    Code:
    WGL Message:WGL: DDraw: Allocate: Create: DDERROR = DDERR_OUTOFVIDEOMEMORY
    That should give you a clue as to what happened.

    Regards,

    Paul McKenzie
    Thank you very much

    actually I am building the code step by step (on my own!)and it was working properly for all the previous steps, but now I encounter this problem since few days and I have no clue about how to solve it. I tried all the ways I am familiar with. but i am a student and trying to learn.

    many thanks for your time
    Last edited by Yohanna; September 27th, 2010 at 01:39 PM.

  2. #17
    Join Date
    Sep 2010
    Posts
    13

    Re: C++ Unhandled exception error

    Quote Originally Posted by itsmeandnobodyelse View Post
    I assume for each call of MD2Model::load there is memory allocated. But you never call cleanup what should free the memory.

    I used cleanup but it really doesn't make a big diference. it only changes the point where the program crashes . at any case I will keep calling it after loading the file.

    Thank you for help
    Last edited by Yohanna; September 27th, 2010 at 02:07 PM.

  3. #18
    Join Date
    Sep 2010
    Posts
    13

    Re: C++ Unhandled exception error

    Quote Originally Posted by Paul McKenzie View Post
    Nowhere do you mention use of a debugger. Are you using one?
    You can't write programs if you're not prepared to debug them on your own. It sounds like you took some code, compiled it, and hoped for the best, and if something goes wrong, throw together arbitrary bits of code to see if the problem goes away.

    Instead, you should have prepared for the inevitable step of having to debug the program at some point, whether that point is now or in the future.
    Code:
    WGL Message:WGL: DDraw: Allocate: Create: DDERROR = DDERR_OUTOFVIDEOMEMORY
    That should give you a clue as to what happened.

    Regards,

    Paul McKenzie

    WGL Message:WGL: DDraw: Allocate: Create: DDERROR = DDERR_OUTOFVIDEOMEMORY

    from thisshould I assume that the problem is about the video memory? if so, any suggestion to do ?

    many thanks again

  4. #19
    Join Date
    Sep 2010
    Posts
    13

    Re: C++ Unhandled exception error

    Quote Originally Posted by Lindley View Post
    The majority of the GPU-side allocations in that code would have occurred in gluBuild2DMipmaps() and glTexImage2D().

    FYI, if you are ever planning to modify an OpenGL texture without resizing it, the second download should be done with glTexSubImage2D() even if you're overwriting the entire image, because that is guaranteed not to do any reallocation.

    Here it looks like a WGL issue, though, so I'm not sure what's going on.
    thank you very much

    based on your note I am going to use subimage then

  5. #20
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: C++ Unhandled exception error

    Just remember you need to glTexImage2d() at least once for each texture, in order to get the memory for TexSubImage to work with!

  6. #21
    Join Date
    Sep 2010
    Posts
    13

    Re: C++ Unhandled exception error

    Quote Originally Posted by Lindley View Post
    Just remember you need to glTexImage2d() at least once for each texture, in order to get the memory for TexSubImage to work with!
    thanks for remark
    I will be aware of that.

    At any case, this part of the code is not reached at the moment because of the mentioned problem. the texture that is meant to be displayed with this part can not be reached before the row_index reaches the maximum value of 128:
    Code:
    if (row_index < 128){glutTimerFunc(100, update, 0);}
    	else {.the texture displayed with this part..}
    I hope this would help to solve the problem but I dont have to try. and any other suggestion would be appreciated

    thanks again

  7. #22
    Join Date
    Oct 2009
    Posts
    577

    Smile Re: C++ Unhandled exception error

    Quote Originally Posted by Yohanna View Post
    thank you

    if I understand properly, you mean the location of the exception?
    the debugger points to the line of code where the pixels values are assigned to the array of pointers after reading the buffer with glReadPixels, the pixels values are saved in an array pixels_index_temp and assigned to pixels_index array

    pixels_index[global_index] = pixels_index_temp[local_index];

    the global array pixels_index is going to be displayed on screen after the whole scanning process

    I hope I answered your question
    many thanks to you

    No, the error message you got means that the process runs out-of-memory. You therefore need to locate all calls where the process requests for memory (and the function called returns a pointer to that memory). Then you need to check whether the memory was freed later. I spotted one call where you load the model but where you never delete the pointer. If that function was called 1024 * 768 times you definitively have a memory problem even for big physical memory...

    If I am right the exception is only a follow-up of the fact that the system can't provide ay more memory.

  8. #23
    Join Date
    Sep 2010
    Posts
    13

    Re: C++ Unhandled exception error

    Quote Originally Posted by itsmeandnobodyelse View Post
    No, the error message you got means that the process runs out-of-memory. You therefore need to locate all calls where the process requests for memory (and the function called returns a pointer to that memory). Then you need to check whether the memory was freed later. I spotted one call where you load the model but where you never delete the pointer. If that function was called 1024 * 768 times you definitively have a memory problem even for big physical memory...

    If I am right the exception is only a follow-up of the fact that the system can't provide ay more memory.
    Thank you so much for help

    I think I did what you suggested (to the best of my knowledge)
    to locat memory I used the expressions such as :
    unsigned char *pixels_index_temp = new unsigned char[144];
    and after using the pointer the memory was freed using delete:
    delete [] pixels_index_temp;
    also, the model and the image loaded were deleted using cleanup function and delete image.
    the function (update) is the only function that can return a pointer to the array pixels_index, but the array should be kept to be displayed within the same function and delete it later.

    this funtion should load the image and the model 128*128 times and form the data array pixels_index_temp, this array will be displayed using OpengGL commands.

    I got the same result with the same messages saying:
    Unhandled exception at 0x7c812afb in OPENGL_......exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012fbb4..

    and
    There is no source code available for the current location.

    and here i sthe last bit of information displayed just before it crashes, these are information about the values stored in the array pixels_index and the address of the array pixels_index_temp before and after using the function delete (the same address):

    row_index 20
    the value stored in pixels_index[384351] B
    row_index 20
    the value stored in pixels_index[384354] /
    row_index 20
    the value stored in pixels_index[384357] รถ
    address of pixels_index_temp BEFORE delete 0012FF1C

    address of pixels_index_temp AFTER delete 0012FF1C

    address of pixels_index 0012FF20 (only 4 bytes after the address of pixels_index_temp)

    address of _model 004097E0

    I hope to have any idea from you.

  9. #24
    Join Date
    Sep 2010
    Posts
    13

    Re: C++ Unhandled exception error

    Quote Originally Posted by Paul McKenzie View Post
    Nowhere do you mention use of a debugger. Are you using one?
    You can't write programs if you're not prepared to debug them on your own. It sounds like you took some code, compiled it, and hoped for the best, and if something goes wrong, throw together arbitrary bits of code to see if the problem goes away.

    Instead, you should have prepared for the inevitable step of having to debug the program at some point, whether that point is now or in the future.
    Code:
    WGL Message:WGL: DDraw: Allocate: Create: DDERROR = DDERR_OUTOFVIDEOMEMORY
    That should give you a clue as to what happened.

    Regards,

    Paul McKenzie

    I am still waiting to hear your opinion

    many thanks in advance

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured