473,500 Members | 1,822 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Memory usage

I have very simple app that has some buttons and labels. When I start my
app, Task manager shows that application is using about 20 mb memory, quite
a lot in my opinion.

Then, I minimize my app. When the app is minimized, it requires only 700 kb
memory. But then the most intresting part: When I normalize my app again
from the taskbar, the app requires only 2 mb memory and in the app nothing
is happened meanwhile.

Why application requires in the first time 20 mb memory and after
minimize-maximize operation the amount is much smaller?

Teemu

Dec 4 '05 #1
3 1753
"Teemu" <ts*****@hotmail.com> schrieb:
I have very simple app that has some buttons and labels. When I start my
app, Task manager shows that application is using about 20 mb memory, quite
a lot in my opinion.
Don't worry about that too much. Memory usage shown for .NET-based
applications is not accurate in task manager because it doesn't show how
much of the memory assigned to the process is really used.
Then, I minimize my app. When the app is minimized, it requires only 700
kb memory. But then the most intresting part: When I normalize my app
again from the taskbar, the app requires only 2 mb memory and in the app
nothing is happened meanwhile.

Why application requires in the first time 20 mb memory and after
minimize-maximize operation the amount is much smaller?


I suggest to take a look at this article:

The working set of an application is trimmed when its top-level window is
minimized
<URL:http://support.microsoft.com/?scid=kb;EN-US;293215>

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

Dec 4 '05 #2

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> kirjoitti
viestissä:%2******************@tk2msftngp13.phx.gb l...
"Teemu" <ts*****@hotmail.com> schrieb:
I have very simple app that has some buttons and labels. When I start my
app, Task manager shows that application is using about 20 mb memory,
quite a lot in my opinion.


Don't worry about that too much. Memory usage shown for .NET-based
applications is not accurate in task manager because it doesn't show how
much of the memory assigned to the process is really used.
Then, I minimize my app. When the app is minimized, it requires only 700
kb memory. But then the most intresting part: When I normalize my app
again from the taskbar, the app requires only 2 mb memory and in the app
nothing is happened meanwhile.

Why application requires in the first time 20 mb memory and after
minimize-maximize operation the amount is much smaller?


I suggest to take a look at this article:

The working set of an application is trimmed when its top-level window is
minimized
<URL:http://support.microsoft.com/?scid=kb;EN-US;293215>


Thanks for your quick answer!

-Teemu

Dec 4 '05 #3
i wish it was more known to the outside world how .Net handles memory

for one of our customers i had to built this code in one of our distributed
apps :-)

Public Sub New()

MyBase.New()

M_dtLastUsage = Date.Now

If IsNothing(oTimer) Then

oTimer = New System.Threading.Timer(oCallback, Nothing,
System.TimeSpan.FromMinutes(0), System.TimeSpan.FromMinutes(1))

End If

End Sub



Private M_dtLastUsage As DateTime

Private oCallback As New TimerCallback(AddressOf OnTick)

Private oTimer As Threading.Timer

Private Declare Auto Function SetProcessWorkingSetSize Lib "kernel32.dll"
(ByVal procHandle As IntPtr, ByVal min As Int32, ByVal max As Int32) As
Boolean

Public Sub OnTick(ByVal stateInfo As Object)

Dim DtCurrent As DateTime = Date.Now

Dim elapsed_time As TimeSpan

elapsed_time = DtCurrent.Subtract(M_dtLastUsage)

If elapsed_time.TotalMinutes >= 1 Then

oTimer.Dispose() : oTimer = Nothing

Try

Dim Mem As Process = Process.GetCurrentProcess()

SetProcessWorkingSetSize(Mem.Handle, -1, -1)

Catch ex As Exception

End Try

End If

End Sub

every time the user performs an action this method is called in a singleton
class

Friend Function fblnGuidExists(ByVal strGuid As String, ByRef stUservals As
SessionVals) As Boolean

M_dtLastUsage = Date.Now

If IsNothing(oTimer) Then

oTimer = New System.Threading.Timer(oCallback, Nothing,
System.TimeSpan.FromMinutes(0), System.TimeSpan.FromMinutes(1))

End If

If htSessions.ContainsKey(strGuid) Then

Dim structSessionVals As SessionVals = CType(htSessions.Item(strGuid),
SessionVals)

With structSessionVals

..dtLastSessionAccess = Date.Now

End With

htSessions.Remove(strGuid)

htSessions.Add(strGuid, structSessionVals)

stUservals = structSessionVals

Return True

End If

End Function
I guess i do not have to tell you what happens here ;-)

by the way the customer is verry happy now

regards

Michel Posseth [MCP]


"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
"Teemu" <ts*****@hotmail.com> schrieb:
I have very simple app that has some buttons and labels. When I start my
app, Task manager shows that application is using about 20 mb memory,
quite a lot in my opinion.


Don't worry about that too much. Memory usage shown for .NET-based
applications is not accurate in task manager because it doesn't show how
much of the memory assigned to the process is really used.
Then, I minimize my app. When the app is minimized, it requires only 700
kb memory. But then the most intresting part: When I normalize my app
again from the taskbar, the app requires only 2 mb memory and in the app
nothing is happened meanwhile.

Why application requires in the first time 20 mb memory and after
minimize-maximize operation the amount is much smaller?


I suggest to take a look at this article:

The working set of an application is trimmed when its top-level window is
minimized
<URL:http://support.microsoft.com/?scid=kb;EN-US;293215>

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

Dec 5 '05 #4

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

Similar topics

8
3653
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
6057
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
460
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
3228
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
422
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
4110
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
4192
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
2833
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
1709
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
2021
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
7018
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
7182
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,...
1
6906
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5490
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,...
1
4923
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4611
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3110
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...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1430
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 ...

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.