I have a program which does some crude animation by moving and changing bitmaps. I'm using repeated CONTROL ADD IMAGE, CONTROL KILL, CONTROL SET IMAGE and CONTROL SET LOC statements. However, after a couple minutes it seems to run out of GDI resources and I can no longer display bitmaps and some fonts "go beserk"? What could cause this?
Announcement
Collapse
No announcement yet.
DDT Bug?
Collapse
X
-
CONTROL SET IMAGE (and the related DDT controls) do not release the previous image handle, that is the responsibility of the programmer. Afterall, it is possible you may be doing something else with the image... the compiler has no way of knowing and does not try to "guess".
The solution to this "problem" is simple... release the image when it no longer required. Here is some psuedo code to show you how to do this at the same time as you would assign a new image to the control:
Code:DIM hBmp AS LONG ... CONTROL SEND CBHNDL, %ImageCtl, %STM_GETIMAGE, %IMAGE_BITMAP, 0 TO hBmp ' get handle to current image CONTROL SET IMAGE CBHNDL, %ImageCtl, "#31" ' Set new image from resource file DeleteObject hBmp ' release the original bitmap image
------------------
Lance
PowerBASIC Support
mailto:[email protected][email protected]</A>Lance
mailto:[email protected]
-
-
brent --
i saw lance's answer.
look http://www.powerbasic.com/support/pb...ead.php?t=1826
or/and post your code.
[this message has been edited by semen matusovski (edited april 29, 2000).]
Comment
-
-
Brent;
I doubt it a bug in the true sense of the word. Likely DDT does things you aren't expecting and I would likely guess that DDTs ability to load an Image into a control was never intended for animation stuff.
You would be better off not destroying the control, but simply load multple bitmaps into memory (get their handles) using SDK style code and then simply "keep swapping" the current handle to the Bitmap in your control using SDK style code. Their is a message for static controls to do this using SendMessage.
If you don't know what DDT is doing under the hood, it is possible to "work against it" by doing something you "assume" should work OK, but may not.
You will have to ask PB for more info about what DDT does under the hood when loading images. Likely it is using the API LoadImage everytime since you are passing the DDT command a Resource name. In true animation you would only load the Images once (not every frame) and then simply swap a Bitmap handle for each frame and then when done destroy all the bitmaps at one time.
------------------
Comment
-
-
It is interesting when 2 or 3 people all reply at about the same instant!
------------------
Lance
PowerBASIC Support
mailto:[email protected][email protected]</A>Lance
mailto:[email protected]
Comment
-
-
Thanks for your responses. I thought the CONTROL KILL would release the handle.
I have a bit-map map of the world and am plotting a satellite. The program recalculates the satellite location and repositions a satellite icon every second.I'll try Lance's solution.
------------------
Brent Boshart
Comment
-
-
Originally posted by Lance Edmonds:
CONTROL SET IMAGE (and the related DDT controls) do not release the previous image handle, that is the responsibility of the programmer. Afterall, it is possible you may be doing something else with the image... the compiler has no way of knowing and does not try to "guess".
The solution to this "problem" is simple... release the image when it no longer required. Here is some psuedo code to show you how to do this at the same time as you would assign a new image to the control:
you might want to add that advice to the next update of the PB/DLL documentation. I would have made the same error, too.
Knuth
------------------
Comment
-
-
It's already on the list.
------------------
Lance
PowerBASIC Support
mailto:[email protected][email protected]</A>Lance
mailto:[email protected]
Comment
-
-
Code:I guess this topic just won't go away, at least not yet. Expecting the programmer to release the image handle is understandable. However, I apparently haven't yet worked out the details successfully. Below is code designed to be as simple as possible. (The RC file for creating the necessary BMP is included.) It creates a modal dialog. This dialog in turn can create other modal dialogs, each of which incorporates an image control and BMP. Using SYSMON.EXE to watch available memory, and even when freeing the resource with DeleteObject, I still see a memory loss (of 36k) each time a dialog w/image is closed. Moreover, this is true even though the call to DeleteObject appears to succeed. (I.e., result& <> 0.) Rem out the line that adds the image control, and the memory loss disappears. I'd appreciate some guidance about how to avoid chewing into available memory in the type of circumstance illustrated below. I might be completely ignorant of some key fact about the process I'm witnessing, and any info would help. #COMPILE EXE #DIM ALL #REGISTER NONE #RESOURCE "DEMO1.PBR" #INCLUDE "WIN32API.INC" '============ DEFLNG A-Z %BMP1 = 10001 DECLARE CALLBACK FUNCTION StartModalBtnClick() DECLARE CALLBACK FUNCTION ExitModalBtnClick&() DECLARE CALLBACK FUNCTION NewDlgMain&() '==================== FUNCTION PBMain&() LOCAL hdlg& dialog new 0, "Main dialog",,, 190, 70, _ (%DS_MODALFRAME OR %WS_POPUP OR %WS_VISIBLE OR _ %WS_CAPTION OR %WS_SYSMENU OR %WS_MINIMIZEBOX), _ 0 To hdlg& control add button, hdlg&, 1001, "Start new modal dialog", 56, 28, 80, 14, _ Call StartModalBtnClick() dialog show modal hdlg& END FUNCTION '==================== CALLBACK FUNCTION StartModalBtnClick&() LOCAL hdlg_new& dialog new 0, "", 150, 120, 160, 70, _ (%DS_MODALFRAME OR %WS_POPUP OR %WS_VISIBLE OR _ %WS_CAPTION OR %WS_SYSMENU OR %WS_MINIMIZEBOX), _ 0 to hdlg_new& control add image, hdlg_new&, %BMP1, "BITMAP_1", 26, 4, 32, 93, , %WS_EX_STATICEDGE control add button, hdlg_new&, 2001, "E&xit", 44, 52, 80, 14, _ %WS_TABSTOP, _ call ExitModalBtnClick&() dialog show modal hdlg_new&, call NewDlgMain& END FUNCTION '==================== CALLBACK FUNCTION NewDlgMain&() LOCAL hbmp&, result& select case cbMsg case %WM_INITDIALOG SetWindowText cbHndl, "New modal dialog " + hex$(cbHndl, 8) case %WM_DESTROY control send cbHndl, %BMP1, %STM_GETIMAGE, %IMAGE_BITMAP, 0 to hbmp& if istrue(hbmp&) then result& = DeleteObject(hbmp&) ''msgbox str$(hbmp&) + str$(result&) '<-- result& <> 0 and thus OK end select END FUNCTION '==================== CALLBACK FUNCTION ExitModalBtnClick&() dialog end cbHndl END FUNCTION #IF 0 /**************************************************************************** demo1.rc produced by Borland Resource Workshop *****************************************************************************/ BITMAP_1 BITMAP { '42 4D 76 14 00 00 00 00 00 00 76 00 00 00 28 00' '00 00 A0 00 00 00 40 00 00 00 01 00 04 00 00 00' '00 00 00 14 00 00 00 00 00 00 00 00 00 00 00 00' '00 00 10 00 00 00 00 00 00 00 00 00 80 00 00 80' '00 00 00 80 80 00 80 00 00 00 80 00 80 00 80 80' '00 00 C0 C0 C0 00 80 80 80 00 00 00 FF 00 00 FF' '00 00 00 FF FF 00 FF 00 00 00 FF 00 FF 00 FF FF' '00 00 FF FF FF 00 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E EE EE EE EE EE EE EE EE EE EE EE EE' 'EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE' 'EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE' 'EE EE EE EE EE EE EE EE EE E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 6E EE E6 66 66 66' '66 66 66 EE EE 66 66 66 66 66 66 66 66 66 66 EE' 'EE 66 66 66 66 66 66 66 66 66 66 EE EE EE EE EE' 'EE EE EE EE EE 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 6E EE EE 66 66 66' '66 66 6E EE EE 66 66 66 66 66 66 66 66 66 66 EE' 'EE 66 66 66 66 66 66 66 66 66 66 EE EE EE EE EE' 'EE EE EE EE EE 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 EE EE E6 66 66' '66 66 EE EE E6 66 66 66 66 66 66 66 66 66 66 EE' 'EE 66 66 66 66 66 66 66 66 66 66 EE EE EE EE EE' 'EE EE EE EE EE 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 6E EE EE 66 66' '66 6E EE EE 66 66 66 66 66 66 66 66 66 66 66 EE' 'EE 66 66 66 66 66 66 66 66 66 66 EE EE E6 66 66' '66 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 EE EE 66 66' '66 6E EE E6 66 66 66 66 66 66 66 66 66 66 66 EE' 'EE 66 66 66 66 66 66 66 66 66 66 6E EE EE 66 66' '66 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 EE EE E6 66' '66 EE EE E6 66 66 66 66 66 66 66 66 66 66 66 EE' 'EE 66 66 66 66 66 66 66 66 66 66 66 EE EE E6 66' '66 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 6E EE EE 66' '6E EE EE 66 66 66 66 66 66 66 66 66 66 66 66 EE' 'EE 66 66 66 66 66 66 66 66 66 66 66 6E EE EE 66' '66 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 EE EE E6' 'EE EE E6 66 66 66 66 66 66 66 66 66 66 66 66 EE' 'EE 66 66 66 66 66 66 66 66 66 66 66 66 EE EE E6' '66 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 6E EE E6' 'EE EE 66 66 66 66 66 66 66 66 66 66 66 66 66 EE' 'EE 66 66 66 66 66 66 66 66 66 66 66 66 6E EE E6' '66 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 6E EE EE' 'EE EE 66 66 66 66 66 66 66 66 66 66 66 66 66 EE' 'EE 66 66 66 66 66 66 66 66 66 66 66 66 6E EE EE' '66 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 66 EE EE' 'EE E6 66 66 66 66 66 66 66 66 66 66 66 66 66 EE' 'EE 66 66 66 66 66 66 66 66 66 66 66 66 66 EE EE' 'E6 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 66 6E EE' 'EE 66 66 66 66 66 66 66 66 66 66 66 66 66 6E EE' 'EE E6 66 66 66 66 66 66 66 66 66 66 66 66 6E EE' 'EE 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 66 6E EE' 'EE 66 66 66 66 66 66 66 66 66 66 66 66 66 EE EE' 'EE EE 66 66 66 66 66 66 66 66 66 66 66 66 66 EE' 'EE E6 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 66 EE EE' 'EE E6 66 66 66 66 66 66 66 66 66 66 66 6E EE EE' 'EE EE E6 66 66 66 66 66 66 66 66 66 66 66 66 6E' 'EE E6 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 6E EE EE' 'EE EE 66 66 66 66 66 66 66 66 66 66 66 6E EE E6' '6E EE E6 66 66 66 66 66 66 66 66 66 66 66 66 6E' 'EE EE 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 EE EE E6' 'EE EE E6 66 66 66 66 66 66 66 66 66 66 EE EE E6' '6E EE EE 66 66 66 66 66 66 66 66 66 66 66 66 66' 'EE EE E6 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 EE EE 66' '6E EE E6 66 66 66 66 66 66 66 66 66 6E EE EE 66' '66 EE EE E6 66 66 66 66 66 66 66 66 66 66 66 66' '6E EE EE 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 6E EE EE 66' '6E EE EE 66 66 66 66 66 66 66 66 66 EE EE E6 66' '66 6E EE EE 66 66 66 66 66 66 66 66 66 66 66 66' '66 EE EE E6 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 EE EE E6 66' '66 EE EE E6 66 66 66 66 66 66 66 66 EE EE 66 66' '66 66 EE EE 66 66 66 66 66 66 66 66 66 66 66 66' '66 6E EE EE 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 6E EE EE 66 66' '66 6E EE EE 66 66 66 66 66 66 66 6E EE EE 66 66' '66 66 EE EE E6 66 66 66 66 66 66 66 66 66 66 66' '66 66 EE EE E6 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 6E EE E6 66 66' '66 66 EE EE 66 66 66 66 66 66 66 EE EE E6 66 66' '66 66 6E EE EE 66 66 66 66 66 66 6E EE EE EE EE' 'EE EE EE EE E6 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 EE EE E6 66 66' '66 66 EE EE E6 66 66 66 66 66 6E EE EE 66 66 66' '66 66 66 EE EE E6 66 66 66 66 66 6E EE EE EE EE' 'EE EE EE EE E6 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 EE EE 66 66 66' '66 66 6E EE E6 66 66 66 66 66 6E EE E6 66 66 66' '66 66 66 6E EE E6 66 66 66 66 66 6E EE EE EE EE' 'EE EE EE EE E6 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 6E EE EE EE EE EE EE EE EE EE EE EE EE' 'EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE' 'EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE' 'EE EE EE EE EE EE EE EE EE E6 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66' '66 66 66 66 66 66' } #ENDIF
Comment
-
-
Code:Still won't go away. Silence on this one seems surprising. To summarize, if you do the following, a 36k memory loss occurs. 1) Create a base dialog using the DDT, modal or modeless. (The example above uses modal dialogs.) 2) Check available memory. (I've been using SYSMON.EXE.) 3) From the base dialog, create another dialog. Call it Dialog A for clarity right now. Use an image control in Dialog A. 4) Close Dialog A, leaving the base dialog running. 5) Recheck available memory. With the sample above, 36k has not been released. Note that the code I've posted uses DeleteObject, and that the call to DeleteObject returns success. So what's going on? (I have one idea. It centers on the assumption that closing a dialog implies always closing the EXE, thereby depending on the OS to clean up.)
------------------
-- Greg
[email protected]
Comment
-
-
I would summize that you are witnessing the way that windows is handling
the memory allocated to your process. If DeleteObject() worked, then the
bitmap itself is being released successfully, but this BMP came from a
resource. Therefore, the 36k block of memory that appears to be retained
will be the memory image of the resource. Theoretically, this block is
marked as discardable - in the days of Win16, discardable memory was very
important.
If free memory starts to get low, Windows should automatically free this
block of memory back to the global heap (so it can be allocated to the
process that requests more memory). Until this occurs, Windows keeps the
memory block allocated to your process, just in case your process needs to
use the resource again.
Try running the same test, but load and release a BMP from a disk file -
you should see all of the memory released when DeleteObject() executes.
BTW, DDT requires that the initial BMP is loaded from a resource file to
ensure that the IMAGE/IMAGEX control can be successfully created. Once
that is done, you can use CONTROL SET IMAGE to change the image to one
loaded from disk (via LoadImage(), etc)
------------------
Lance
PowerBASIC Support
mailto:[email protected][email protected]</A>Lance
mailto:[email protected]
Comment
-
-
Lance--
Thanks. Will experiment with the test you've suggested.
------------------
-- Greg
[email protected]
Comment
-
Comment