473,976 Members | 22,871 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Start as Minimized Memory Usage

When minimizing Visual Basic application, working memory is greatly reduced
from about 20 MB to only about 2 MB. However I want the application to
start as minimized, and most of the time it will remain minimized, never
being brought to normal or maximized view and consequently then minimized.

However when started minimized the working memory stays at 20 MB until the
app is restored to normal/maximized and then minimized.

How do I get the working memory down to 2 MB programmaticall y when starting
the app minimized?

TIA
Jan 11 '07 #1
6 1938
Allen

Over a year ago there was a nice piece of code in the MSDN magazine that
starts an application in the System Tray withought actually drawing the form
until the icon was double-clicked. Spent about 30 mins looking for this code
but I don't remember which month it was in.

Most people will assign a TrayNotifyIcon control to a form & then run the
app from Sub Main, adding the icon to the tray, but an invisible instance of
the form is still there, which can be proved but enumerating the Desktop
windows using a callback function, yet the MSDN Magazine code article
removed that form, which would be absolutely perfect for your needs. I only
wished I could find that code for you.

This is the URL for the MSDN Magazine code:

http://msdn.microsoft.com/msdnmag/code.aspx

Sorry, I cannot be of more help,

Newbie Coder
Jan 11 '07 #2
What you are talking about is the 'WorkingSet'. If you continue to refer to
is as 'working memory' then you all you are going to do is confuse everyone
including youself.

Have a look at the documentation on the System.Environm ent.WorkingSet6 4
property for some more information.

By 'when started minimized', I assume that you are refering to setting the
WindowState property of your startup form at design time.

Instaed of setting it at design time you could try setting it in your
Form.Load event handler.
"Allen" <Al***@discussi ons.microsoft.c omwrote in message
news:4E******** *************** ***********@mic rosoft.com...
When minimizing Visual Basic application, working memory is greatly
reduced
from about 20 MB to only about 2 MB. However I want the application to
start as minimized, and most of the time it will remain minimized, never
being brought to normal or maximized view and consequently then minimized.

However when started minimized the working memory stays at 20 MB until the
app is restored to normal/maximized and then minimized.

How do I get the working memory down to 2 MB programmaticall y when
starting
the app minimized?

TIA


Jan 11 '07 #3
Allen

Take a look at the 'Application Main' class in the Windows Forms folder of
the September 2005 MSDN Magazine. Its the 'Weather Alerts' example

Has a nice, simple Toast Window too

Here's the direct download:

http://download.microsoft.com/downlo...ndowsForms.exe

I hope this will help

Newbie Coder
Jan 11 '07 #4
Hello

as long as the application domain is loaded the memory will be reserved
for further processing

if your comp would run low on resources and the app does not need the memory
at the moment ( cause it is idle ,,, the memory would be given back and
needs to be reclaimed )

with a windows form application you can see this behavior to ( or did you
really thought a clean form needs about +- 25 megs in .Net ? )

there is a way you can bypass this behavior however it comes with a small
price ,,,,
i wrote once a remoting project , and had my customer complaining about the
memory consumption , so i digged a litle bit deeper and came with this
solution

my project ( wich is a singleton ) starts a timer that periodicly checks a
datetime var to see how manny time has passed after it was last called
if this intervall is >= 1 minute it will call SetProcessWorki ngSetSize()
wich will trim the data usage to a minimum see below code ( sorry VB.Net
-) )
Private M_dtLastUsage As DateTime

Private oCallback As New TimerCallback(A ddressOf OnTick)

Private oTimer As Threading.Timer

Public Sub OnTick(ByVal stateInfo As Object)

Dim DtCurrent As DateTime = Date.Now

Dim elapsed_time As TimeSpan

elapsed_time = DtCurrent.Subtr act(M_dtLastUsa ge)

If elapsed_time.To talMinutes >= 1 Then

oTimer.Dispose( ) : oTimer = Nothing

SetProcessWorki ngSetSize()

End If

End Sub

Public Sub New()

M_dtLastUsage = Date.Now

If IsNothing(oTime r) Then

oTimer = New System.Threadin g.Timer(oCallba ck, Nothing,
System.TimeSpan .FromMinutes(0) , System.TimeSpan .FromMinutes(1) )

End If

End Sub

Private Declare Auto Function SetProcessWorki ngSetSize Lib "kernel32.d ll"
(ByVal procHandle As IntPtr, ByVal min As Int32, ByVal max As Int32) As
Boolean

Friend Sub SetProcessWorki ngSetSize()

Try

Dim Mem As Process = Process.GetCurr entProcess()

SetProcessWorki ngSetSize(Mem.H andle, -1, -1)

Catch ex As Exception

End Try

End Sub

The drawback of this method is that the framework needs to reclaim the
memory again so in theory your prog should be a few miliseconds slower as it
could be.

So it is more cosmetical as that it does really have a purpose as the prog
is actually gone to the swap same as a minimized application ( physical and
virtual memory thingy )
Regards
Michel Posseth [MCP]

"Stephany Young" wrote:
What you are talking about is the 'WorkingSet'. If you continue to refer to
is as 'working memory' then you all you are going to do is confuse everyone
including youself.

Have a look at the documentation on the System.Environm ent.WorkingSet6 4
property for some more information.

By 'when started minimized', I assume that you are refering to setting the
WindowState property of your startup form at design time.

Instaed of setting it at design time you could try setting it in your
Form.Load event handler.
"Allen" <Al***@discussi ons.microsoft.c omwrote in message
news:4E******** *************** ***********@mic rosoft.com...
When minimizing Visual Basic application, working memory is greatly
reduced
from about 20 MB to only about 2 MB. However I want the application to
start as minimized, and most of the time it will remain minimized, never
being brought to normal or maximized view and consequently then minimized.

However when started minimized the working memory stays at 20 MB until the
app is restored to normal/maximized and then minimized.

How do I get the working memory down to 2 MB programmaticall y when
starting
the app minimized?

TIA


Jan 11 '07 #5
A solution that works very well is:
http://www.coversant.net/dotnetnuke/...d=88&EntryID=4

--
Chris Mullins, MCSD.NET, MCPD:Enterprise , MVP C#
http://www.coversant.net/blogs/cmullins

"Allen" <Al***@discussi ons.microsoft.c omwrote in message
news:4E******** *************** ***********@mic rosoft.com...
When minimizing Visual Basic application, working memory is greatly
reduced
from about 20 MB to only about 2 MB. However I want the application to
start as minimized, and most of the time it will remain minimized, never
being brought to normal or maximized view and consequently then minimized.

However when started minimized the working memory stays at 20 MB until the
app is restored to normal/maximized and then minimized.

How do I get the working memory down to 2 MB programmaticall y when
starting
the app minimized?

TIA


Jan 11 '07 #6
Haven't tried it yet, but looks very nice and clean. Thanks much for code.

"Chris Mullins [MVP]" wrote:
A solution that works very well is:
http://www.coversant.net/dotnetnuke/...d=88&EntryID=4

--
Chris Mullins, MCSD.NET, MCPD:Enterprise , MVP C#
http://www.coversant.net/blogs/cmullins

"Allen" <Al***@discussi ons.microsoft.c omwrote in message
news:4E******** *************** ***********@mic rosoft.com...
When minimizing Visual Basic application, working memory is greatly
reduced
from about 20 MB to only about 2 MB. However I want the application to
start as minimized, and most of the time it will remain minimized, never
being brought to normal or maximized view and consequently then minimized.

However when started minimized the working memory stays at 20 MB until the
app is restored to normal/maximized and then minimized.

How do I get the working memory down to 2 MB programmaticall y when
starting
the app minimized?

TIA


Jan 12 '07 #7

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

Similar topics

2
3365
by: Mike Peretz | last post by:
I am trying to optimize my C# program, but no matter what I try the application keeps eating memory. I verified all the references and even got special software to count references. I made sure all the reference count reaches zero for all the objects that are no longer used. I also call Dispose as much as possible. Regardless, the memory is not freed. Even if I force the GC, some memory gets freed but not much.
5
6106
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 loss even though I seem to be allocaitng everything; help would be *vastly* appreciated. What am I doing wrong here? I thought I was doing everything correctly (setting things to null, for example) but none of the memory seems to get replaced. ...
40
10898
by: Brian Jorgenson | last post by:
On my web page, I have a few hyperlinks with target frame of _blank. The hyperlink brings up a second window, but everytime I click on thie hperlink, it keeps bringing up a new window and not defaulting the the first active window. How do I make a hyperlink point to the active window? I don not want the hyperlink to default to the same page. I do want a second window but only a second window and not multiple pages.
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 test the stuff, I keep to open that child data form for about 10 times. the memory usage shown in GC and task manager both increase. Then I close all those forms. and perform GC collect. The memory usage shown in GC falls, however, the memory...
3
4170
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 periodically. What happens, is that the app reads the contents of a text file line by line into an ArrayList. Each element of the ArrayList is a string representing a record from the file. The ArrayList is then processed, and the arraylist goes out of...
6
3727
by: Ganesan selvaraj | last post by:
I using C# .net. i want to split the text files based of the some condition. my source text file size may be 4 kb to 4 gb. some time when i split the i got the "out of memory exception. when i read from the file i read the 10mb and split the this content and clear the buffer and read the second 10 mb and so on. How can i rectify the problem?
20
4267
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 memory usage drops to a couple hundred KB. Why? Is there anything I should to to prevent this? I have compiled in release and deactivated all forms of debugging, I think! Thanks, Philip
19
24781
by: Oliver Neumann | last post by:
Hello, im new to c# and i got an app with a notifyicon. Now i want to start the app only with the notifyIcon, so that the Main-Form doesnt show up. The form itself is used at the entrance point of the app: Application.Run(new MainFrame()); Now i tried to use this to hide the Form and show up the trayBarIcon with this in the constructor of the form.
1
2061
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 the objects for which that memory was allocated are no longer live in the process. This is only a leak if peak memory goes up again each time you create any new objects. Try repeated allocations of a large dictionary and observe how memory...
0
10353
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
11818
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
11408
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
10083
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
7604
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6415
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...
0
6557
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
5153
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
4731
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.