all groups > dotnet windows forms > august 2003 >
You're in the

dotnet windows forms

group:

Simple program mem hog



Simple program mem hog Stephen
8/31/2003 9:50:51 PM
dotnet windows forms: I have a fairly simple program with 2 forms, one having
only a toolbar with 5 buttons and a simple status bar,
and 8 menu entries in VB. The other form is larger with
a couple small images and several labels. I have 4 or 5
complex classes but no instances of them declared and my
program still eats up 18-19 MB of mem according to Task
Manager just by running it and displaying both forms. I
even excluded the form with images from the project and
it still took 16-17 MB just to run it. The only vars I
have declared are 1 integer and an instance of each form,
so there is nowhere for a mis-written class to be
reserving such an expansive area of memory. I only have
the minimum references like VisualBasic, System, Data,
Drawing, and Forms. Does the .NET framework require such
resources just to run?

Re: Simple program mem hog Joe White
9/1/2003 1:14:34 AM
Program startup involves creating lots of objects that are used briefly,
then set loose. What you're seeing is that those objects have not yet
been garbage-collected. .NET doesn't free unused memory immediately;
you have to wait until the garbage collector runs. That way it can free
lots of objects at once and run more efficiently. It makes your .NET
app look like a memory hog, but really, it will automatically compact
the heap and then give the unused memory back whenever another app needs
it. So, short answer: don't worry about it.


[quoted text, click to view]
Re: Simple program mem hog v-yiy NO[at]SPAM online.microsoft.com
9/2/2003 3:31:31 AM
Hello Stephen,
Thanks for Joe's explanation and I'd like to provide more information,
I think the following discussion thread may clarify why the program uses so
many memory, and in addition why it can be reduced by minimize then restore.
Sorry the discussion maybe a bit too technical.
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF&threadm=%232Wqt7G8
BHA.2488%40tkmsftngp04&rnum=1&prev=/groups%3Fselm%3D%25232Wqt7G8BHA.2488%254
0tkmsftngp04%26oe%3DUTF

thanks!

Kind regards,

Ying-Shen Yu [MS]
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
--------------------
| Message-ID: <3F52E3CA.30901@hotmail.com>
| Date: Mon, 01 Sep 2003 01:14:34 -0500
| From: Joe White <ip255@hotmail.com>
| User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2)
Gecko/20030208 Netscape/7.02
| X-Accept-Language: en-us, en
| MIME-Version: 1.0
| Subject: Re: Simple program mem hog
| References: <035801c37044$9e3e35b0$a501280a@phx.gbl>
| Content-Type: text/plain; charset=us-ascii; format=flowed
| Content-Transfer-Encoding: 7bit
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: ip68-96-138-248.om.om.cox.net 68.96.138.248
| Lines: 1
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:51369
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| Program startup involves creating lots of objects that are used briefly,
| then set loose. What you're seeing is that those objects have not yet
| been garbage-collected. .NET doesn't free unused memory immediately;
| you have to wait until the garbage collector runs. That way it can free
| lots of objects at once and run more efficiently. It makes your .NET
| app look like a memory hog, but really, it will automatically compact
| the heap and then give the unused memory back whenever another app needs
| it. So, short answer: don't worry about it.
|
|
[quoted text, click to view]
| > I have a fairly simple program with 2 forms, one having
| > only a toolbar with 5 buttons and a simple status bar,
| > and 8 menu entries in VB. The other form is larger with
| > a couple small images and several labels. I have 4 or 5
| > complex classes but no instances of them declared and my
| > program still eats up 18-19 MB of mem according to Task
| > Manager just by running it and displaying both forms. I
| > even excluded the form with images from the project and
| > it still took 16-17 MB just to run it. The only vars I
| > have declared are 1 integer and an instance of each form,
| > so there is nowhere for a mis-written class to be
| > reserving such an expansive area of memory. I only have
| > the minimum references like VisualBasic, System, Data,
| > Drawing, and Forms. Does the .NET framework require such
| > resources just to run?
| >
| > Stephen
|
|
AddThis Social Bookmark Button