Re: StretchDIBits Failing Due to ERROR_NOT_ENOUGH_MEMORY - Programmer

This is a discussion on Re: StretchDIBits Failing Due to ERROR_NOT_ENOUGH_MEMORY - Programmer ; It could mean not enough GDI memory. It is a common mistake to think that task manager shows anything useful; it doesn't typically correlate with any form of reality that matters. It is unforutnate that in an era of 4GB ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Re: StretchDIBits Failing Due to ERROR_NOT_ENOUGH_MEMORY

  1. Re: StretchDIBits Failing Due to ERROR_NOT_ENOUGH_MEMORY

    It could mean not enough GDI memory. It is a common mistake to think that task manager
    shows anything useful; it doesn't typically correlate with any form of reality that
    matters.

    It is unforutnate that in an era of 4GB physical memory on cosumer machines that GDI space
    is artificially limited. I should be able to get as much as I want and need.
    joe
    On Thu, 24 Jan 2008 15:08:07 -0800 (PST), PeterOut wrote:

    >I am using MS Visual C++ .NET version 7.1.3088 on Win XP 5.1 SP 2.
    >Physical memory available to Windows = 1.095 GB.
    >
    >After several calls to StretchDIBits, with the same parameters,
    >StretchDIBits returns 0 (no scan lines copied). GetLastError returns
    >8 (ERROR_NOT_ENOUGH_MEMORY).
    >
    >When this happens, I use the Windows task manager and observe that the
    >program is using only 12.8 MB of memory. Available physical memory is
    >1.4 GB. Kernel memory has 112028 total, 95724 paged and 16308
    >nonpaged. PF usage is 603 MB.
    >
    >I can continue the program to completion and it closes with no memory
    >leaks. I would be grateful for any ideas about why this might be
    >happening and if there are any tools to trace where large amounts of
    >memory may be being allocated.
    >
    >Many thanks in advance,
    >Peter.

    Joseph M. Newcomer [MVP]
    email: newcomer@flounder.com
    Web: http://www.flounder.com
    MVP Tips: http://www.flounder.com/mvp_tips.htm

  2. Re: StretchDIBits Failing Due to ERROR_NOT_ENOUGH_MEMORY

    See below...
    On Fri, 25 Jan 2008 11:01:56 -0800 (PST), PeterOut wrote:

    >On Jan 25, 8:15 am, Joseph M. Newcomer wrote:
    >> It could mean not enough GDI memory. It is a common mistake to think that task manager
    >> shows anything useful; it doesn't typically correlate with any form of reality that
    >> matters.
    >>
    >> It is unforutnate that in an era of 4GB physical memory on cosumer machines that GDI space
    >> is artificially limited. I should be able to get as much as I want and need.
    >> joe

    >
    >Hi Joe,
    >
    >Thanks for your reply. I checked my code again and found that I was
    >allocating ppvBits, pbmi (BITMAPINFO *) and various palettes several
    >times w/o freeing them. It's still not clear why I was not getting
    >memory leak messages from MS Visual C++. I usually do when I have
    >memory leaks.

    ****
    Because "memory leaks" deal with the program heap, and palettes and bitmaps do not exist
    on the heap, they exist in the GDI heap, which is owned by GDI. So there is no way a
    memory heap allocator is going to have a clue that you are leaking GDI resources.

    The App Verifier might detect this; certainly Bounds Checker for Windows did.
    joe
    ****
    >
    >Thanks again,
    >Peter.

    Joseph M. Newcomer [MVP]
    email: newcomer@flounder.com
    Web: http://www.flounder.com
    MVP Tips: http://www.flounder.com/mvp_tips.htm

+ Reply to Thread