CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Resource Leak

  1. #1
    Join Date
    Aug 2001
    Location
    India
    Posts
    4

    Resource Leak

    Hi All

    I am developing a 'User Interface' application using MFC. In Windows2000 platform my application works fine. But when I port it to Windows98, it gives an error saying 'Low Resources'. When I checked with the 'ResourceMeter' tool, the system resource vanishes drastically for some operations which use the 'Device Context'. Actually in my program nowhere I allow any resources unreleased (including device contexts).

    Can anyone please give me some suggestions on this?
    Any sort of input regarding this matter is highly appreciated.

    Thanks and Regards

    Ramanand


  2. #2
    Join Date
    Dec 2001
    Posts
    381

    Re: Resource Leak

    Actually, also in Win2000 your program doesn't run fine, but Win2000 is very stable system, so you need to waste more resources to crush your program. In Win98 you see this quickly. There are number of rules working with graphic resources:
    1) Any created resource should be released immidiately when you don't need them
    2) Every time you use SelectObject keep pointer to previous graphic object and restore it later
    3) Instead of keeping large number of GDI resources such as bitmaps or memory DC it's better to keep only bitmap bits and create GDI objects when necessary.

    In Win2000 Task manager you can select GDI Objects column (View - Select Column) and see how many GDI objects are opened in your program. Compare this with other graphic programs.

    If you have Bounds Checker, run your program under it, it can give you a lot of information about your code.


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