System.OutofMemory exception

I have a VB .Net console mode program running on XP Professional that uses a lot of collections and internal text arrays.

It had been running OK for several months until about a month ago when I started getting an intermitent System.OutofMemory exception from within the VB.Net Visual Basic DLL. Sometimes it runs fine and others I get the error exit out and rerun and I am fine.

The data all gets loaded at startup which is when the error occurs.

I know .Net is supposed to do it's own memory garbage collection but is it possible that the garbage collection is not occurring fast enough to keep up with the program's allocation or am I hitting some other limit.

Is there anything I can do to recover when I get this exception instead of just exiting out and rerunning the program?

Has anyone else run into this?


Comments

  • : I have a VB .Net console mode program running on XP Professional that uses a lot of collections and internal text arrays.
    :
    : It had been running OK for several months until about a month ago when I started getting an intermitent System.OutofMemory exception from within the VB.Net Visual Basic DLL. Sometimes it runs fine and others I get the error exit out and rerun and I am fine.
    :
    : The data all gets loaded at startup which is when the error occurs.
    :
    : I know .Net is supposed to do it's own memory garbage collection but is it possible that the garbage collection is not occurring fast enough to keep up with the program's allocation or am I hitting some other limit.
    :
    : Is there anything I can do to recover when I get this exception instead of just exiting out and rerunning the program?
    :
    : Has anyone else run into this?
    :
    :

    Im cant say what is causing your error, although I dont think its a problem with the garbage collection being too slow.

    You know you can capture errors when they occur and continue or fail gracefully. Check out the "try" and "catch" keywords.

    One other thing, I noticed that I received the same error message when I tried to load a picture format it didnt recognise into a picturebox. So, the error may have nothing to do with memory :)
  • I found a workaround that did point to the garbage collection thread getting behind in it's work and an out of memory condition resulting.

    Increasing system virtual memory had no effect but there is a system parameter under control panel that allows you to give preference to system background processes vs. application for resources.

    By changing the preference to system background processes, my problem went away. It seems like to me that garbage collection is a system background process and it now is getting enough cpu to stay ahead of the application's memory allocation. Just a theory but it does seem to make sense.

    I know I could have caught the exception but the issue was what did I need to do before I resumed! Insert a pause to allow the garbage collection thread to catchup and then resume?
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories