Results 1 to 2 of 2

Thread: Out Of memory

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Location
    Egypt
    Posts
    179

    Out Of memory

    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...

  2. #2
    Hyperactive Member SoftwareMaker's Avatar
    Join Date
    Mar 2001
    Location
    Elbonia with Dilbert and Wally
    Posts
    322
    you have, more or less, found the root of the problem.

    End statement is like pressing the STOP button on the VB menu toolbar. It just ends abruptly. Nothing is freed and there are tons of memory leakages. You should unload the Form which the control is on and all variables belonging to the project will terminate.

    A good habit to learn is to explicitly terminate references you have no use for as you go along. This requires a lot of designing skills and thats what good projects are all about 80% Designing and Planning, 20% Coding

    Set rs=nothing, Set objConnect = Nothing...etc

    Use your debugging tools like the locals and watch window to see where the memory is leaking and which references to objects are still in hiding....

    Man, I cant wait for the Garbage Collection features of VB.net to replace the inefficiencies of the Release Function of COM
    William T
    Software Architect / Chief Software Developer
    Softwaremaker.Net Pte Ltd
    http://www.Softwaremaker.net

    *** Things are always the darkest before they go pitch black ***

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