PDA

Click to See Complete Forum and Search --> : Out Of memory


bmarzouk
Aug 14th, 2001, 07:38 PM
Hello,

I have the problem of "Out of memory".
I am using VB6 SP5.
This problem doesn't happen at the first time I run the program, It always happen after running
the program and Ending it for about 7 to 10 times. After "Out of memory" appears at the last time,
I have to close VB and run it again, some times I have to restart my machine.
This problem is more noticed in Win 98 than Win NT or Win 2000.

Now, I will tell some details about my program, so you can help me find a solution.

My program Is a multimedia program, that uses several ActiveX controls I have made, These ActiveX
controls are Controls that load many pictures, for example, my Listbox ocx has 3 pictures to be loaded
for each of Up arrow , Down arrow, Left arrow, right arrow, Vertical Scroller and Horizontal Scroller.

In UserControl_Initialize event I set the variables that I store pictures in it to null picture,
The same I do in UserControl_Terminate event, like that:

Set mvarUpMouseOutPicture = LoadPicture("") ' The picture of the Up button when the mouse out of the control
Set mvarUpMouseUpPicture = LoadPicture("") ' The picture of the Up button when the mouse enters the control
Set mvarUpMouseDownPicture = LoadPicture("") ' The picture of the Up button When the user press the mouse down on the control
.
.
.
.

And so on, about 16 variant variable are set the same at UserControl_Initialize and UserControl_Terminate events

I noticed that UserControl_Terminate is not fired when "End" statement Executed, but
Unload the form will fire UserControl_Terminate, so the pictures variables will be freed.

Does this describe the problem cause, or there are another reasons for this problem.

Thank you for your time you have spent reading all of this message...

Sastraxi
Aug 14th, 2001, 08:17 PM
Undocumented and "un-ended" (meaning that there is another call to make to free the memory) API calls do this. Make sure there are none of those. Eg. CreateDC requires a DeleteDC or ReleaseObject or something of the sort. Also, I believe you can set the pictures to Nothing. This would free up the memory (better?) than the loadpicture("").