473,387 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Memory usage in VB.Net

I have a memory problem when running a VB.Net application.
The application uses a from frmMain from which another form can be opened:

Private Sub OpenTheNewForm()
dim frm as New frmSecondform
frm ShowDialog()
End Sub

At some point in time the second form is closed and the program returns to
the main form frmMain:

Private Sub CloseTheSecondForm()
Me.Close()
End Sub

When I look at the memory usage during execution of the program (using
Windows' Taskmanager) I see the memory usage increase with several Mb's as
soon as the second form is loaded. That is normal, I guess.
But when I close this form only a few Kb's of memory are released. Loading
the second form again increases the memory usage by several Mb's again. And
so on and so on.
After opening the second form a couple of times, the total memory used by
the program may have increased to as much as 150-200 Mb.

I'm sure that this is not how it is intended to be. But I haven't find a
solution yet. I have tried the Dispose-statement, to no effect.

What am I missing here? How do I release unused memory.
Please note, that I am rather a newbie. Thanks.

Jul 21 '05 #1
2 5747
Under the .NET Framework, the release of memory is not deterministic and is
done/controlled by the GC (Garbage Collector).

The following two parts article by Jeff Richter is a good introduction to
the GC of .NET:
http://msdn.microsoft.com/msdnmag/is...I/default.aspx

This article is a little outdated and make reference to some features of the
Beta 1.0 which don't exist anymore but the overall idea is still true.

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
"JosR" <Jo**@discussions.microsoft.com> wrote in message
news:92**********************************@microsof t.com...
I have a memory problem when running a VB.Net application.
The application uses a from frmMain from which another form can be opened:

Private Sub OpenTheNewForm()
dim frm as New frmSecondform
frm ShowDialog()
End Sub

At some point in time the second form is closed and the program returns to
the main form frmMain:

Private Sub CloseTheSecondForm()
Me.Close()
End Sub

When I look at the memory usage during execution of the program (using
Windows' Taskmanager) I see the memory usage increase with several Mb's as
soon as the second form is loaded. That is normal, I guess.
But when I close this form only a few Kb's of memory are released. Loading
the second form again increases the memory usage by several Mb's again.
And
so on and so on.
After opening the second form a couple of times, the total memory used by
the program may have increased to as much as 150-200 Mb.

I'm sure that this is not how it is intended to be. But I haven't find a
solution yet. I have tried the Dispose-statement, to no effect.

What am I missing here? How do I release unused memory.
Please note, that I am rather a newbie. Thanks.

Jul 21 '05 #2
When you show a form using ShowDialog, after you close it, you must
also call it's dispose method. This is not true of a form shown by
just calling Show.

Jul 21 '05 #3

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

Similar topics

8
by: rbt | last post by:
Would a Python process consume more memory on a PC with lots of memory? For example, say I have the same Python script running on two WinXP computers that both have Python 2.4.0. One computer has...
5
by: Justice | last post by:
Currently I'm doing some experimenting with the XMLHTTP object in Javascript. Now, the XMLHttp object is asynchronous (at least in this case), and the following code causes a significant memory...
2
by: tomvr | last post by:
Hello I have noticed some 'weird' memory usage in a vb.net windows app The situation is as follows I have an app (heavy on images) with 2 forms (actually there are more forms and on starting...
6
by: Tom | last post by:
We have a VERY simple .NET C# Form Application, that has about a 23MB Memory Footprint. It starts a window runs a process and does a regular expression. I have done a GC.Collect to make sure that,...
2
by: Jarvis | last post by:
I've made a testing program to test the memory usage of some Data Forms. I create a MDI parent form with one single MDI child form, which is a Data Form generated by .NET Data Form Wizard. To...
3
by: Ian Taite | last post by:
Hello, I'm exploring why one of my C# .NET apps has "high" memory usage, and whether I can reduce the memory usage. I have an app that wakes up and processes text files into a database...
20
by: Philip Carnstam | last post by:
How come .Net applications use so much memory? Every application I compile uses at least 10 MB of memory, even the ones consisting of only a form and nothing else. If I minimize them though the...
13
by: Ilias Lazaridis | last post by:
How to detect memory leaks of python programms, which run in an environment like this: * Suse Linux 9.3 * Apache * mod_python The problem occoured after some updates on the infrastructure....
1
by: yzghan | last post by:
Hi all, I feel that my python script is leaking memory. And this is a test I have: log.write(" " + "test() ... memory usage: " + " ".join(repr(i/(1024*1024)) for i in getMemInfo()) + "\n") m...
1
by: Jean-Paul Calderone | last post by:
On Tue, 22 Apr 2008 14:54:37 -0700 (PDT), yzghan@gmail.com wrote: The test doesn't demonstrate any leaks. It does demonstrate that memory usage can remain at or near peak memory usage even after...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...

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.