Results 1 to 6 of 6

Thread: Handling Out of Memory

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2003
    Location
    Ludwigshafen
    Posts
    12

    Handling Out of Memory

    Hi,

    I have a VB6 Project running on a Windows 2000 machine with SP4.

    I make a referecne to a dll given by a particular tool. This dll allows me to access the data inside the projects created by this tool. There exists a Workset class which needs to be initialized before using other methods in this class.

    VB Code:
    1. Dim wst as New CWorkset
    2. wst.Init(USER, PASSWORD. DBPATH)

    The above set of statements proceed normally when I run it the first time. As I am in the devlopment phase of the project I tend to Debug the code and stop at different places and restart the project. When the Debugger comes across the above two lines of code for the second time it gives me the errror message "Out of Memory". The workaround at present is to restart the machine and proceed. However I would like to know the real reason behind this problem and take care of it without having to restart the system.

    I am sure it is not the second statement which is failing because I tested these in VB.NET and captured the error in the first statement with the help of the line numbers(Erl).

    Regards,
    Ranjith.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    first of all Erl is available in all versions of VB - it's just that previous to VB.Net you have to type line numbers in manually (or use a tool like MZTools )

    right then, what do you do to close wst when you finish with it? is there a method that you need to call (like with Init)?

    assuming there is, you should have something like this:
    VB Code:
    1. wst.terminate   '(terminate is just a guess)
    2. set wst = Nothing  'Release memory

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2003
    Location
    Ludwigshafen
    Posts
    12

    Setting to Nothing

    Hi,

    Thanks for the reply.

    I do not goto the cleanup code everytime I debug my app.
    So the resource might not be release at all time.
    I need a workaround or reason to stop restarting the machine.

    Regards,
    Ranjith.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    if you debug and then exit suddenly (like pressing the 'stop' button), then the memory will still be used - VB will not do it for you.

    You have three choices:
    1) Reboot regularly
    2) Exit the program properly - not always a good idea (especially if it would take a long time to get there)
    3) Run the cleanup code manually just before you terminate code execution - probably the best bet.

    There are two ways of doing option 3, the first is to drag the code execution (the yellow line in the IDE) to the cleanup code, but this is only possible if it is in the current procedure. The second option is to create a sub/function to do all the cleanup operations, and simply call it from the immediate window.

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2003
    Location
    Ludwigshafen
    Posts
    12

    One step further

    Hi,

    Thank you for the choices.

    I chose for the 3rd option. Irrespective of making sure that the cleanup code is called everytime when I come across the declaration it fails with the "Out of Memory" error.

    However now I think other things might affect the whole process. The wst.Init function checks whether there is a license to run this tool and then logs into the database with the password provided.

    Can the faliure of the Init function affect the instancing of the Workset class later? Possible. Is there a way out?


    Regards,
    Ranjith.

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    definitely, if the init fails then it almost certainly wont work properly.

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