CreateCompatibleBitmap failed
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 3 123 LastLast
Results 1 to 15 of 32

Thread: CreateCompatibleBitmap failed

  1. #1
    Join Date
    Jul 2001
    Posts
    293

    CreateCompatibleBitmap failed

    Hello,

    I has a problem with CreateCompatibleBitmap.

    the usage in short:
    ------------
    CBitmap bm;
    CClientDC dc(NULL);
    bm.CreateCompatibleBitmap(&dc,4096,4096);
    -----------

    If I understand it right, it needs 4096*4096*3= approx. 50MB of video memory.
    Is this correct?

    For my current project it is used once in the app. I has to restart the app many times. No problem half of the day.
    But then I get the error 8: "insufficient memory". It can only resolved if I restart the PC.

    Is the problem in my app?
    Does win XP grabs memory and do not release it?
    Is it really the video memory?
    Can I check the free video memory?

    Thx for any helps!

    Ralf

  2. #2
    Join Date
    Apr 1999
    Posts
    27,423

    Re: CreateCompatibleBitmap failed

    Quote Originally Posted by Ralf Schneider View Post
    Is the problem in my app?
    Does win XP grabs memory and do not release it?
    Is it really the video memory?
    Can I check the free video memory?
    Do any of your other applications show a problem? I bet they don't, so the problem is with your application.

    Also, posting those 3 lines of code tells us absolutely nothing except the parameters you're using to call the function. How would those 3 lines look if your application was working correctly? There would be no difference.

    Unless we have your entire application, run it, and see the behaviour, then no one will be able to tell you exactly what you're doing wrong. More then likely you are allocating resources and never releasing them.

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; June 13th, 2012 at 03:44 AM.

  3. #3
    Join Date
    Jul 2001
    Posts
    293

    Re: CreateCompatibleBitmap failed

    Hello Paul,

    do win XP not release all the memory used by my app, when I terminate it?

    Ralf

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,927

    Re: CreateCompatibleBitmap failed

    Of course it does.

    But then I get the error 8: "insufficient memory". It can only resolved if I restart the PC.
    Did you try it on some other XP system? It might be a video driver problem.
    Last edited by Igor Vartanov; June 13th, 2012 at 09:51 AM.
    Best regards,
    Igor

  5. #5
    Join Date
    Jul 2002
    Posts
    2,505

    Re: CreateCompatibleBitmap failed

    Possibly your program leaks resources. Check this with Task Manager. See whether Handle Count, GDI Objects and Memory Usage are constantly growing when the program is running. To see all these counters, use View - Select Columns dialog in the Task Manager.

  6. #6
    Join Date
    Jul 2001
    Posts
    293

    Re: CreateCompatibleBitmap failed

    Hello Alex,

    how can I see all these counters in the task manager on win xp?
    I do not find it!

    Please help.

  7. #7
    Join Date
    Apr 1999
    Posts
    27,423

    Re: CreateCompatibleBitmap failed

    Quote Originally Posted by Ralf Schneider View Post
    Hello Alex,

    how can I see all these counters in the task manager on win xp?
    I do not find it!

    Please help.
    View -> Select Columns

    Regards,

    Paul McKenzie

  8. #8
    Join Date
    Jul 2001
    Posts
    293

    Re: CreateCompatibleBitmap failed

    Hello,

    the view menu of win xp has not such an item....

  9. #9
    Join Date
    Jul 2001
    Posts
    293

    Re: CreateCompatibleBitmap failed

    Quote Originally Posted by Alex F View Post
    Possibly your program leaks resources. Check this with Task Manager. See whether Handle Count, GDI Objects and Memory Usage are constantly growing when the program is running. To see all these counters, use View - Select Columns dialog in the Task Manager.
    Hello Alex,

    you mean, that these resources will not be released automtically when the app is terminated???
    What could it be that interfered with resources used by CreateCompatibleBitmap?

    Ralf

  10. #10
    Join Date
    Apr 1999
    Posts
    27,423

    Re: CreateCompatibleBitmap failed

    Quote Originally Posted by Ralf Schneider View Post
    Hello Alex,

    you mean, that these resources will not be released automtically when the app is terminated???
    Fix your application, then you don't need to worry about this.

    Regards,

    Paul McKenzie

  11. #11
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,276

    Re: CreateCompatibleBitmap failed

    Quote Originally Posted by Ralf Schneider View Post
    Hello,

    the view menu of win xp has not such an item....
    I have no idea what you mean by "view menu of win xp" but View menu of Task Manager in Win XP does have this item.
    Victor Nijegorodov

  12. #12
    Join Date
    Jul 2002
    Posts
    2,505

    Re: CreateCompatibleBitmap failed

    Of course, all resources are released when application is terminated. But if your application allocates some resources (like GDI objects) all the time without releasing them, finally some of these allocations fails. This is called resource leak. So, learn your application behavior with Task Manager.
    For example, you see that your application consumes 50 GDI objects. 1 hour later - 70 objects, several hours later - 200 objects etc. This is resource leak.
    The same applies to the memory, handles, threads etc. - actually, all types of resources.

  13. #13
    Join Date
    Jul 2001
    Posts
    293

    Re: CreateCompatibleBitmap failed

    Hello Alex,

    ok, I will check it.
    But the Task Manager View-menu has only these items:
    (translated from German)
    - Update
    - Speed for Update
    - CPU-history
    - Show kernal-times

    ?????

    thx.
    Ralf

  14. #14
    Join Date
    Apr 1999
    Posts
    27,423

    Re: CreateCompatibleBitmap failed

    Quote Originally Posted by Ralf Schneider View Post
    Hello Alex,

    ok, I will check it.
    But the Task Manager View-menu has only these items:
    (translated from German)
    - Update
    - Speed for Update
    - CPU-history
    - Show kernal-times

    ?????

    thx.
    Ralf
    My version of XP Task Manager certainly does have the "Select Columns..." option in the View Menu. If you don't believe me, do a google search and you will find that it does exist.

    Regards,

    Paul McKenzie

  15. #15
    Join Date
    Jul 2001
    Posts
    293

    Re: CreateCompatibleBitmap failed

    Hello Paul,

    of course, I do believe you.
    But that do not help me....

Page 1 of 3 123 LastLast

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center