Contents Up Previous Next

After using memory DCs and bitmaps under Windows, I get system crashes.

Here's some correspondence that helps explain this phenomenon and its solution.

From: Markus Meisinger <Markus.Meisinger@at.ac.uni-linz.risc>
Message-Id: <199406241203.AA09143@melmac.risc.uni-linz.ac.at>
To: wxwin-users@ed.aiai
Subject: SOLUTION to strange problems of yesterday
Status: RO

hi wxWindows programers

i wrote yesterday:

>I have encountered some strange problems with the sample programs under
>MS-WINDOWS 3.11. (they work fine under UNIX/LINUX)
>
>The problems arise if i e.g quit the minimal sample program. During the run
>of the program no problems appear. But after it stops than the whole
>system crashes (not always, but quite often :)!
>
>If the system crashes, not only the sample program produces an
>UNRECOVERABLE APPLICATION ERROR, but also the most other programs running
>at the same time (PROGMAN, FILEMAN, WINMETER, ...) stop their work with
>a severe error. :(
>
>Any help would be greatly appreciated! Or is there a patch available, because
>a guess their is a bug in freeing the system resources ...

The actual problem causing the strange behaviour was a buggy wxWindows program
of mine running some minutes before and not the sample programs, CTL3D or
FAFALIB

Because i used a wxMemoryDC in which i selected a dynamicaly created bitmap.
During the quiting process i freed this bitmap which was selected in the
wxMemoryDC. But wxWindows also freed this bitmap during deleting the DC and
... the rest you know

SO, BE AWARE IF YOU DELETE BITMAPS! 

Never delete a bitmap which is selected into a DC if the DC will be deleted.
The bitmap will be deleted by the DC!
But i did it !!! :) and it resulted in a system wide crash of MS-WINDOWS
(in Motif it works fine (why?))
The funny thing with this crash is that the system doesn't immediately crash,
instead it works fine for a few minutes until ANY other program gets into
some memory conflict. After this application error each program still running
complains problems with the memory and stops. The last thing you see is
the standard windows background color (if you are lucky:)
I never saw such a system wide crash WOU :) in some sense it was funny :)

Hope you don't make the same errors as i did!

Markus