Results 1 to 6 of 6

Thread: out of memory

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    125

    out of memory

    hello, I am having problems with the releaseDC function in my application.

    According to microsoft:

    Remarks

    The application must call the ReleaseDC function for each call to the GetWindowDC function and for each call to the GetDC function that retrieves a common DC.
    and in each sub I use it as follows:

    VB Code:
    1. public sub whatever()
    2.  Dim hWndDesk As Long
    3.  Dim hDCDesk As Long
    4.   hWndDesk = GetDesktopWindow()
    5.   hDCDesk = GetWindowDC(hWndDesk)
    6.  
    7.  ' do whatever in the sub
    8.  
    9.   'right before the sub ends i release the DC that i got at the beginning of it
    10.  Call ReleaseDC(hWndDesk, hDCDesk)
    11. end sub

    But that doesnt seem to work, i still get a memory leak. In the sub of the app. that im having my issue in, the only thing i do using the DC is use the getpixel function. So, does that mean everytime i use the getpixel function i should use the releasedc function after it? Thanks
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: out of memory

    anyone here familiar with releaseDC?
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: out of memory

    any ideas what i could be doing wrong here?
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

  4. #4
    Lively Member
    Join Date
    Aug 2002
    Posts
    106

    Re: out of memory

    are u test that the leak is in this part ao the code only ?
    Did u tray DeleteDC ?

  5. #5
    Lively Member
    Join Date
    May 2005
    Posts
    74

    Re: out of memory

    Hi,


    Try using GetDc instead of GetwindowDc.

    VB Code:
    1. Dim hWndDesk As Long, hDCDesk As Long
    2.     Dim  r As Long
    3.  
    4.     'Get the handle of the desktop window
    5.     hWndDesk = GetDesktopWindow()
    6.  
    7.     'Get the desktop window's device context
    8.     hDCDesk = GetDC(hWndDesk)
    9.  
    10.     'Release the device context
    11.     r = ReleaseDC(hWndDesk, hDCDesk)


    Thanks
    Sanjivani

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: out of memory

    Imosha, its not in any other part, because im not using a device context in any other procedure. Is there any way i could trap a memory leak error?

    Sanjivani, The getpixel function returns a negitive value using GetDC and not GetWindowDC... I have no idea why.

    Thanks guys,
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

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