473,809 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.WindowSta te = 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
programmaticall y, 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 2759
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********@gma il.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.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.WindowSta te = 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
programmaticall y, 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********@gma il.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 'SetProcessWork ingSetSize':

<URL:http://msdn.microsoft. com/library/en-us/dllproc/base/setprocessworki ngsetsize.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.microso ft.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.web 101.discountasp .net/GdncStore/free/Articles/The%20Memory%20 Mystery.htm>

Allocation Profiler src
<URL:http://www.gotdotnet.c om/Community/UserSamples/Details.aspx?Sa mpleGuid=325432 5d-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
4385
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 gives me an error from microsoft's error report and asks me to send or not send the error, i chose and then it quits. The error report won't let me copy the data, but i gather it's pretty useless information unless you have the source code to visual...
1
3757
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 work, and I have to run Task Manager to exit C++. I haven't installed any service packs for Visual Studio, thinking I wouldn't need them until I started programming more heavily. On the installation it mentioned debug symbols for Win NT, which I...
5
7237
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 error) Save your work and restart Visual Studio .NET." has anyone seen this bug and can you confirm one way or the other whether or not it can corrupt your source files? (by 'corrupt' i mean: do anything to it that will cause it to fail to load and...
26
10891
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 compiles the same solution much faster (about 10 seconds for the first project). My home computer is only marginally faster than the one I have at the office (P4 2.53 vs. P4 2.4, same amount of RAM). On the slow machine, the CPU usage is very low,...
97
5560
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 the first place. Anyone else heard about this development? The Master
23
4347
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 to chars are just how you deal with strings, and pointers to pointers to char just give you arrays of strings. What is the advantage of this vs. languages with a string type?
3
6070
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 Pervasive ODBC driver. The devenv.exe process hangs and will not respond with about 50% cpu usage and about 100 megs of memory used. I am running it on an Athlon 64 bit dual core with 32 bit Windows XP pro. I have 2 megs of memory so I don't...
4
3105
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 applications into Visual Basic.Net. My managers main thought is that Visual Basic 6 is (or has!) stopped being supported by Microsoft.
3
10519
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 closes unexpectedly and without any error message being displayed, or error messages written to the system logs. Visual Studio closes when I attempt to open an ASP.NET Web application (not Web site) solution for which IIS is set as the project's...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10637
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10115
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9199
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.