472,804 Members | 989 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,804 software developers and data experts.

Visual Basic App Memory Issue

I am new to VB, but not new to programming. I am using VB.Net 2003 and
I have written a small app to monitor several running processes and
everything is fine except the memory usage. When the app starts up,
even though there is very little on the form, the memory usage
displayed in task manager jumps to 24MB.
If I minimize the app, usage drops to .6MB. If I then restore the app,
it moves back up to 3-6MB.

Here are a few details about the program:

1. There is a custom control in a separate dll that does the real work.
Each instance of the control monitors 1 app. It takes a small bit of
XML in the form of an XmlElement for initialization. It contains 4
16x16 32bit images, 3 buttons, 2 labels, a tooltip, and a subform for
configuration.
2. The custom controls are stored on a custom tabpage that controls
positioning and size. This tabpage raises a few events that affect the
size of the main form and the form icon.
3. The main form has 4 icons stored in an array and 4 images are stored
in an image list for the tab pages, a menu with 8 entries, and a tab
control.
4. By default, and without an XML file to load from, there are no
custom tab pages or controls loaded, yet the memory issue still occurs.
5. Up until the main form is shown (Form.Show()) and minimized
(Form.WindowState = FormWindowState.Minimized), the memor usage is
between 24 and 30 MB. Once the form is shown and minimized by hand,
the usage drops to 600k. While testing, I wrapped the app in a module
that immediately showed and minimized the form. Doing this
programmatically, the memory usage dropped to 5MB.

Is there anything I can do to reduce the memory footprint of this app?

Nov 21 '05 #1
3 2705
ignore it, thats just the way JIT compilers work with Garbage collection...
the memory system you see in task manager doesn't know how to correctly
display memory usage in a .NET app so you get large ammounts of "allocated"
memory that isn't even in use by the app showing up..

<ba********@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
I am new to VB, but not new to programming. I am using VB.Net 2003 and
I have written a small app to monitor several running processes and
everything is fine except the memory usage. When the app starts up,
even though there is very little on the form, the memory usage
displayed in task manager jumps to 24MB.
If I minimize the app, usage drops to .6MB. If I then restore the app,
it moves back up to 3-6MB.

Here are a few details about the program:

1. There is a custom control in a separate dll that does the real work.
Each instance of the control monitors 1 app. It takes a small bit of
XML in the form of an XmlElement for initialization. It contains 4
16x16 32bit images, 3 buttons, 2 labels, a tooltip, and a subform for
configuration.
2. The custom controls are stored on a custom tabpage that controls
positioning and size. This tabpage raises a few events that affect the
size of the main form and the form icon.
3. The main form has 4 icons stored in an array and 4 images are stored
in an image list for the tab pages, a menu with 8 entries, and a tab
control.
4. By default, and without an XML file to load from, there are no
custom tab pages or controls loaded, yet the memory issue still occurs.
5. Up until the main form is shown (Form.Show()) and minimized
(Form.WindowState = FormWindowState.Minimized), the memor usage is
between 24 and 30 MB. Once the form is shown and minimized by hand,
the usage drops to 600k. While testing, I wrapped the app in a module
that immediately showed and minimized the form. Doing this
programmatically, the memory usage dropped to 5MB.

Is there anything I can do to reduce the memory footprint of this app?

Nov 21 '05 #2
Is there any easy way to see how much memory is being used?

Nov 21 '05 #3
<ba********@gmail.com> schrieb:
I am new to VB, but not new to programming. I am using VB.Net 2003 and
I have written a small app to monitor several running processes and
everything is fine except the memory usage. When the app starts up,
even though there is very little on the form, the memory usage
displayed in task manager jumps to 24MB.
If I minimize the app, usage drops to .6MB. If I then restore the app,
it moves back up to 3-6MB.


The behavior caused by minimizing a form is not specific to .NET
applications only. It is a feature of the Windows/Explorer shell. If an
application is minimized, Windows removes the working set memory from the
application by calling the Win32 function 'SetProcessWorkingSetSize':

<URL:http://msdn.microsoft.com/library/en-us/dllproc/base/setprocessworkingsetsize.asp>

Windows supposes that minimized applications will not be used for some time
and this memory will be made available to other processes. When restoring
the window the application gets the memory back:

PRB: An Application's Working Set Is Trimmed When Its Top-Level Window Is
Minimized
<URL:http://support.microsoft.com/?scid=kb;EN-US;293215>

This behavior is by design and it doesn't make sense to worry about it.

The Memory Mystery
<URL:http://getdotnetco.web101.discountasp.net/GdncStore/free/Articles/The%20Memory%20Mystery.htm>

Allocation Profiler src
<URL:http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=3254325d-a4aa-4bb3-aa86-c72d5104ec74>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: John | last post by:
I have a problem, it's not with any code I have because... there is no code. When I run a blank visual basic 6 form, it opens up just fine. When I add a text box, a caption, and a button... it...
1
by: Adam Sawyer | last post by:
Hi I'm having trouble getting Visual Studio 6 Enterprise (C++) to work on my Win XP Pro (SP 1 - latest .NET framework). Whenever I try to compile a C program, it just hangs, cancel build doesn't...
5
by: K. Shier | last post by:
when attempting to edit code in a class file, i see the bug "Visual Basic ..NET compiler is unable to recover from the following error: System Error &Hc0000005&(Visual Basic internal compiler...
26
by: Bruno Jouhier [MVP] | last post by:
I'm currently experiencing a strange phenomenon: At my Office, Visual Studio takes a very long time to compile our solution (more than 1 minute for the first project). At home, Visual Studio...
97
by: Master Programmer | last post by:
An friend insider told me that VB is to be killled off within 18 months. I guess this makes sence now that C# is here. I believe it and am actualy surprised they ever even included it in VS 2003 in...
23
by: TefJlives | last post by:
Hi all, I'm learning a bit about C, and I have a few questions. I'm not trying to insult C or anything with these questions, they're just honestly things I don't get. It seems like pointers...
3
by: Edwin Smith | last post by:
I have a 2 form project in VS2005 that now hangs whenever I try to do anything with the second form. This seems to have started when I added some SQL tables from a Pervasive v.9 database using the...
4
by: Chris Asaipillai | last post by:
Hi there My compay has a number of Visual Basic 6 applications which are front endeed onto either SQL Server or Microsoft Access databases. Now we are in process of planning to re-write these...
3
by: Johnson | last post by:
I'm not sure if this is an IIS 5.1 issue or ASP.NET issue, or Visual Studio 2008 issue -- thus posting to 3 groups. Please don't be offended. The problem I'm encountering is that Visual Studio...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.