473,387 Members | 1,724 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

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 1748
"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
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:
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
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...

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.