Results 1 to 3 of 3

Thread: Memory leak

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2001
    Location
    Moscow
    Posts
    3

    Memory leak

    code is:

    //////////////////////
    HGLRC bmp_hglrc;
    HDC bmp_hdc;

    HDC memDC = CreateCompatibleDC(NULL);
    int bpp = GetDeviceCaps(memDC,BITSPIXEL);
    HBITMAP bmp = CreateBitmap(w,h,1,bpp,0);
    SelectObject(memDC,(HBITMAP)bmp);
    bmp_hdc = memDC;

    BITMAP bmInfo;

    GetObject(bmp,sizeof(BITMAP),&bmInfo);

    PIXELFORMATDESCRIPTOR pfd;
    memset(&pfd,0, sizeof(PIXELFORMATDESCRIPTOR));
    pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
    pfd.nVersion = 1; // Version number
    pfd.dwFlags = PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_TYPE_RGBA;
    pfd.iPixelType = PFD_TYPE_RGBA;
    pfd.cColorBits = (BYTE)bmInfo.bmBitsPixel;
    pfd.cDepthBits = 32; // 32-bit depth buffer
    pfd.iLayerType = PFD_MAIN_PLANE ; // Layer type

    int pixelFormat = ChoosePixelFormat(bmp_hdc,&pfd);
    BOOL success = SetPixelFormat(bmp_hdc,pixelFormat,&pfd);

    bmp_hglrc=wglCreateContext(bmp_hdc);

    wglMakeCurrent(bmp_hdc,bmp_hglrc);

    Draw(); <---- take memory and never free
    wglMakeCurrent(bmp_hdc,NULL);

    wglMakeCurrent(NULL,NULL);
    wglDeleteContext(bmp_hglrc);
    //////////////////////

    code from http://www.opengl.org/discussion_boa...ML/001072.html


    [This message has been edited by Hance (edited 02-27-2001).]

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Augsburg, Germany
    Posts
    334

    Re: Memory leak

    So, so code of the Draw() function would be of some interest

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2001
    Location
    Moscow
    Posts
    3

    Re: Memory leak

    oop's i forget to delete DC:
    DeleteDC(bmp_hdc)

Similar Threads

  1. Memory leak
    By Pedja in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 09-05-2008, 11:17 AM
  2. Memory Leak
    By GamerYZ in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-18-2007, 09:57 PM
  3. ati drivers leak memory :-(
    By imported_john in forum OpenGL: Linux
    Replies: 0
    Last Post: 09-16-2005, 10:58 PM
  4. memory leak
    By davidib in forum OpenGL: Windows
    Replies: 2
    Last Post: 02-19-2005, 08:52 AM
  5. Memory leak
    By link19 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 08-21-2001, 12:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean