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...
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?
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...
Re: System.OutOfMemoryException
Re: System.OutOfMemoryException
Re: System.OutOfMemoryException
Upgrade to 2GB, 1GB is not good enough today.
Re: System.OutOfMemoryException
will my problem be solved if i do this?
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.
Re: System.OutOfMemoryException
This amount keeps changing but i've captured this one: 146372 Kb
Re: System.OutOfMemoryException
Definitely upgrade your RAM.
Re: System.OutOfMemoryException
ok i'l do so...Thanks for the help :)
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.
Re: System.OutOfMemoryException
If you run Vista, your PC is a snail. If it's XP, it's a snail too.
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.
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:
Quote:
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?
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.)
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.
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.