VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 300,440 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,506 people online right now. Registration is fast and FREE... Join Now!




High Memory Usage

 

High Memory Usage

mishipal

1 Jul, 2009 - 04:10 AM
Post #1

D.I.C Head
**

Joined: 4 May, 2009
Posts: 77



Thanked: 1 times
My Contributions
i have two forms : Form1 and Form2

when i start application form 1 opens up, the memory usage is 10MB
then i open form 2 and close form 1, the memory usage is 25MB.
Again i close form2 and open form1, then the memory usage is 30MB.

Why is this so that form 1 has different memory usage at different times...?

any idea to reduce this ....?

User is offlineProfile CardPM
+Quote Post


Amrykid

RE: High Memory Usage

1 Jul, 2009 - 04:55 AM
Post #2

D.I.C Addict
Group Icon

Joined: 16 Dec, 2008
Posts: 899



Thanked: 10 times
Dream Kudos: 350
My Contributions
QUOTE(mishipal @ 1 Jul, 2009 - 05:10 AM) *

i have two forms : Form1 and Form2

when i start application form 1 opens up, the memory usage is 10MB
then i open form 2 and close form 1, the memory usage is 25MB.
Again i close form2 and open form1, then the memory usage is 30MB.

Why is this so that form 1 has different memory usage at different times...?

any idea to reduce this ....?

it highly depends whats on your form or what its doing.
User is offlineProfile CardPM
+Quote Post

LoveIsNull

RE: High Memory Usage

1 Jul, 2009 - 08:35 AM
Post #3

Disbanding my Ignorance
****

Joined: 10 Mar, 2009
Posts: 536



Thanked: 45 times
My Contributions
The way memory management works in .NET is, simply put...
Memory is managed for you, once you are done using an object, it goes out of scope or you call it's Dispose method, you're not actually freeing up the memory that was being consumed. Rather, you are indicating that the object is no longer needed.
The Garbage Collector actually de-allocates and compacts the memory, so long as an object is not referenced subsequently, it will be collected by the GC. This is non-deterministic, you wont know exactly when it is going to happen and although you can call GC.Collect() it is kind of an expensive operation, so it is best to let it be.

If it concerns you that much, be sure you dispose of any object that require it, or utilize Using statements. Don't reference anything anymore than you have to, even just to set it to nothing.
CODE
Dim myVar As String = "Hello, world!"
MessageBox.Show(myVar)

myVar = Nothing 'This could actually keep it in memory longer


Read up on garbage collection in the .Net Framework.
User is offlineProfile CardPM
+Quote Post

prabh

RE: High Memory Usage

1 Jul, 2009 - 09:52 AM
Post #4

D.I.C Regular
Group Icon

Joined: 27 Dec, 2008
Posts: 289



Thanked: 8 times
Dream Kudos: 25
My Contributions
tell me the way you exit the form
User is offlineProfile CardPM
+Quote Post

mishipal

RE: High Memory Usage

1 Jul, 2009 - 07:45 PM
Post #5

D.I.C Head
**

Joined: 4 May, 2009
Posts: 77



Thanked: 1 times
My Contributions
i exit the forms using me.close

the form1 has only 4 combos and does same job everytime it opens so why it takes diff memory
User is offlineProfile CardPM
+Quote Post

Matthew Blanch

RE: High Memory Usage

1 Jul, 2009 - 08:00 PM
Post #6

New D.I.C Head
Group Icon

Joined: 18 Aug, 2008
Posts: 35



Thanked: 2 times
Dream Kudos: 50
My Contributions
Can you upload a copy of the project?

Matthew Blanch.

This post has been edited by Matthew Blanch: 1 Jul, 2009 - 08:02 PM
User is offlineProfile CardPM
+Quote Post

LoveIsNull

RE: High Memory Usage

2 Jul, 2009 - 01:54 AM
Post #7

Disbanding my Ignorance
****

Joined: 10 Mar, 2009
Posts: 536



Thanked: 45 times
My Contributions
Another consideration here, besides reading mine and others previous posts and replying to them with more specific and appropriate follow up questions. But also, are you talking about your application specifically as in you compiled it and are running it outside of Visual Studio?
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 01:11AM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month