|
-
Apr 23rd, 2004, 01:19 PM
#1
Thread Starter
Fanatic Member
out of memory?
i got an error when i run an app. half way...:An unhandled exception of type 'System.Out of memory Exeception' occured in mscorlib.dll
wat happen? i a pc of 512 k ram
-
Apr 23rd, 2004, 07:04 PM
#2
I wonder how many charact
What happened was you ran out of memory. I could write some code that would devour your available memory in two seconds, and hold it for ransom while it begged for mercy.
Sorry I couldn't be more specific about the error, but you didn't post any additional info about the error, like where it occured, or such.
Usually these errors happen when you do not properly dispose of images, release system resources (fonts, brushes)... etc...etc..
-
Apr 23rd, 2004, 07:28 PM
#3
Thread Starter
Fanatic Member
yesh you are right!....the error occurs in the codes where i have placed images on every form of my app....like:
Me.images...=GetObject(...images..)...(sorry i didnt remember the codes clearly cuz i am posting this forum at home while the work is done in my office )
....bascially how do i properly dispose of images, release system resources (fonts, brushes)... etc...etc..?
and i thing o note that the portion where errors occurs is not in my 'written codes' ..thanks you!
Last edited by Goh; Apr 23rd, 2004 at 07:44 PM.
-
Apr 23rd, 2004, 07:44 PM
#4
I wonder how many charact
will probably solve ur problems. You will have to recheck your code and be sure you not missing a few of these.
As far as forms, same thing applies, dispose of them when they are not needed.
-
Apr 23rd, 2004, 07:49 PM
#5
Thread Starter
Fanatic Member
why do i need to dispose images that in.net? i dun do that in vb6 ...where do i dispose the images? and furthermore i have put labels with big fonts on it..do i need to resize the font also?
-
Apr 23rd, 2004, 07:57 PM
#6
I wonder how many charact
You have to dispose of the image explicity, because they consume much resources, for some reason, it is the proper way, it kinda tags it for disposal as soon as possible.
Resizing is easier under .Net, but it still can never be a non-issue. There are many things left to consider, and frankly, I haven't worked with Windows Forms applications in over 5 months (moved to internet dev), and you really need to start a new thread for a question about fonts.
-
Apr 23rd, 2004, 08:03 PM
#7
Thread Starter
Fanatic Member
wow thanks for for information....can i conclude that whenever i switch from one form1 to another form2..i would first have to dispose the images on the form1....etc....am i right?
-
Apr 23rd, 2004, 08:23 PM
#8
I wonder how many charact
Once you are done with an image, you should dispose of it. Without seeing your code, its hard to tell you what to do.
As an example, use a 2mb image file for this test.
Start a new windows application, throw a button on the form.
Double-click the button and throw the below code in the button_click event.
Change myFile to the full path and filename of your test image file. Remember it should be 2mb or more to see the results clearly.
Now build and run your app.
Open up Task Manager (ctrl-alt-del), and under Processes, look for WindowApplication1 or whatever the new project ends up being called.
Now click the button on your form about 20 times as fast as you want.
You should see the memory usage jump dramatically. Now, go back and uncomment the block of code that is initially commented out, and rerun the test.
You will see it jumps, but always recovers to a manageable level.
VB Code:
Dim fs As New IO.FileStream("F:\Joy's Wedding\IMG_3563.jpg", IO.FileMode.Open)
Dim s As Image = Image.FromStream(fs)
Dim r As Image = Image.FromStream(fs)
Dim t As Image = Image.FromStream(fs)
Dim g As Image = Image.FromStream(fs)
Dim x As Image = Image.FromStream(fs)
Dim h As Image = Image.FromStream(fs)
fs.Close()
'''keep this block commented out for first test
's.Dispose()
'r.Dispose()
't.Dispose()
'g.Dispose()
'x.Dispose()
'h.Dispose()
''''''''''''''''
-
Apr 25th, 2004, 09:20 AM
#9
Thread Starter
Fanatic Member
hm...but i did not hard codeto put the image on the form initially...i put the image in IDE....that means i have to dispose the image when the next form is shown?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|