Results 1 to 18 of 18

Thread: System.OutOfMemoryException

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2010
    Posts
    27

    System.OutOfMemoryException

    Hello i have written a program in vb.net of about 550 lines and consists of 15 forms till now but the program is not completed yet. Each time i add a new form and when i save it i get 'System.OutOfMemoryException was thrown'. I used to close vb.net and open it again then it would work fine but now i'm getting this exception even if i do so. I have 66 GB free space available in my hard disk can't understand why i'm gettin this exception. Can someone please give me any suggestions?

    Thanks...

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: System.OutOfMemoryException

    You are getting this when you are saving or opening the solution, not during debugging, right? That number of forms is trivial, in itself. Is there anything unusual about the forms? Are you using lots of resources (especially images) in the project?
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2010
    Posts
    27

    Re: System.OutOfMemoryException

    Thanks for the reply...i'm getting this exception when saving...Ya i'm using a lot of images in the forms...

  4. #4
    Lively Member
    Join Date
    Dec 2010
    Posts
    89

    Re: System.OutOfMemoryException

    How much RAM you have?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Dec 2010
    Posts
    27

    Re: System.OutOfMemoryException

    1 GB of RAM...

  6. #6
    Lively Member
    Join Date
    Dec 2010
    Posts
    89

    Re: System.OutOfMemoryException

    Upgrade to 2GB, 1GB is not good enough today.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Dec 2010
    Posts
    27

    Re: System.OutOfMemoryException

    will my problem be solved if i do this?

  8. #8
    Lively Member
    Join Date
    Dec 2010
    Posts
    89

    Re: System.OutOfMemoryException

    Yep, your problem is that you run out of RAM when saving.
    Throw up Task Manager, performance tab and where it says physical memory, tell us the amount in Available.

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Dec 2010
    Posts
    27

    Re: System.OutOfMemoryException

    This amount keeps changing but i've captured this one: 146372 Kb

  10. #10
    Lively Member
    Join Date
    Dec 2010
    Posts
    89

    Re: System.OutOfMemoryException

    Definitely upgrade your RAM.

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Dec 2010
    Posts
    27

    Re: System.OutOfMemoryException

    ok i'l do so...Thanks for the help

  12. #12
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: System.OutOfMemoryException

    The issue does appear to have to do with RAM, as that is the only memory that exception would really be noticing. 1GB is kind of low, and this is the easiest thing to try, and all other options are decidedly less pleasing. Therefore, if you can do the upgrade, then that is definitely the best option. Of course, it is also one of the few solutions in the programming section of this forum that costs actual money. Fortunately, the result will be more RAM, even if it doesn't solve the problem.
    My usual boring signature: Nothing

  13. #13
    Lively Member
    Join Date
    Dec 2010
    Posts
    89

    Re: System.OutOfMemoryException

    If you run Vista, your PC is a snail. If it's XP, it's a snail too.

  14. #14
    Banned
    Join Date
    Mar 2009
    Posts
    764

    Re: System.OutOfMemoryException

    right click command line (the line with windows start), task manager, processes, end processes you don't need it should free up some ram, then if you don't get the problem again you know you should ad ram memory or just uninstall needless programs.

  15. #15
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    Re: System.OutOfMemoryException

    No, the issue does not appear to be about RAM. If you want to understand OutOfMemory exceptions, read this article.

    In particular, this line:
    By now it should be clear why “out of memory” errors usually have nothing to do with how much physical memory you have, or how even how much storage is available. It’s almost always about the address space, which on 32 bit Windows is relatively small and easily fragmented.
    I would suggest that Visual Studio is being ridiculous and loading all those images into memory. A better upgrade than more RAM (which won't increase the address space) would be perhaps an upgrade to 64-bit. However, that's a bit extreme. Is there anyway you can handle the images differently? Maybe change them from Embedded Resources to loosely associated files on disk? (Disclaimer: no idea if that will make any difference)

    Also, consider if you actually need that many images?

  16. #16
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    Re: System.OutOfMemoryException

    Actually, thinking about it, Visual Studio is still a 32-bit process, so upgrading to 64-bit won't necessarily get you anything (although I think you should be able to get up to 4GB addressable space rather than 2GB/3GB, as the OS doesn't eat up any of the address space.)

  17. #17

    Thread Starter
    Junior Member
    Join Date
    Dec 2010
    Posts
    27

    Re: System.OutOfMemoryException

    As suggested, i upgraded my RAM to 2GB but i'm still getting the same problem...When i click on save, it tells me that there's insufficient memory to execute this operation. I don't know what to do now. My project is stuck. Please help.

  18. #18
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: System.OutOfMemoryException

    I think EvilG has the next things to try at the end of his post #16. I would certainly try holding just the file names and loading the files as needed. It may not be the ultimate solution, as loading the files in this fashion might not be sufficient, but as a test, it would be relatively easy to implement. If it solves your problem (and it should if you go to the length of hardcoding the filenames into the program such that they are part of the code itself rather than any resource), then you have positively determined that the images are the cause (there is at least one alternative, which is a corrupted VS installation). From there...well, there are options with various levels of ugliness.
    My usual boring signature: Nothing

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