CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Out Of Memory

  1. #1
    Join Date
    Feb 2000
    Location
    America
    Posts
    130

    Out Of Memory

    Is there a way I can find out if my program tries to do something but the computer doesn't have enough memory? This has happened before but it crashes instead of telling me. Is there a way I can build an error handler for this so the user is notified when they are low on memory? I've been told VB can't check to see how much is left, is that true? Any help would be appretiated, thanx.


  2. #2
    Join Date
    Feb 2000
    Location
    Indiana
    Posts
    308

    Re: Out Of Memory

    Possibly using error handling and checking to see if the Object is instantiated would work. I've never thought of that before.

    on error resume next
    set cn = new ADODB.Connection
    If cn is nothing then
    'Handle the error
    else
    'Work with the object
    End If



    This might be something that the new Try...Catch structure will help us with.


  3. #3
    Join Date
    Feb 2000
    Location
    America
    Posts
    130

    Re: Out Of Memory

    I don't see how that answers my question. what does that have to do with memory? What you put would just check if the object can be assigned....that has nothing to do with memory, least not to my knowledge.


  4. #4
    Join Date
    Feb 2000
    Location
    Indiana
    Posts
    308

    Re: Out Of Memory

    Not being able to create the object would likely indicate one of two things:
    1) The Object is not correctly registered on the client machine
    2) The machine was unable to create the Object because there is not enough memory




  5. #5
    Join Date
    Feb 2000
    Location
    America
    Posts
    130

    Re: Out Of Memory

    oh ok, cool. thanx


  6. #6
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Out Of Memory

    As an aside, I've seen this happen before when a program has got itself stuck in a loop (usually a recursive one, eg. where a paint / resize event calls a routine that in itself, raises a paint / resize event).

    A good way to get out of this situation is to use a static variable in the (possible) offending routine :

    eg.

    private Sub Form_Resize()
    static bInHere as Boolean
    '
    If bInHere then Exit Sub ' quit possible loop
    '
    bInHere = true
    '
    ' Do some processing
    '
    ' ......
    '
    bInHere = false
    End Sub




    - it may help with the out-of-memory error.



    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

  7. #7
    Join Date
    Feb 2000
    Location
    America
    Posts
    130

    Re: Out Of Memory

    No, this is simply because I am out of memory. I know I'm out of memory because right before my program crashes, all the other open programs tell me I'm too low on memory to perform the task i wish to perform, etc.


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

Featured