?
Solved

Memory Utilization Problem in .NET

Posted on 2004-11-01
10
Medium Priority
?
161 Views
Last Modified: 2010-04-24
Dear Experts,

According to .net documentation, Garbage Collector should free the memory. we analysed and found following things.

1- We have 40 modules in window desktop application in VB.net. Every module opening adds 1 or 2 MB to Memory utilization statistics displayed in Task Manager. Now see, a user was engaged in public sector dealing. He has to open forms 100 times a day and has to perform different tasks. Continuous addition to memory causes application to become slower. User has to shutdown Application and then restarts if he needs to free Memory which is not acceptable.  

Please Advice...we have tried to destroy objects explicitly and we have call system.GC.Collect also with that.......but no improvement

Regards,
Fahim
0
Comment
Question by:fahimnxb
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 10

Accepted Solution

by:
prakash_prk earned 800 total points
ID: 12462982

Destroy all the objects
Clear the content in treeview befor destroy it
if you have image lists clear the images before destroy it
If you have webbrowser control navigate it to "about:blank" and destroy it

After destroy all the objects
call
GC.Collect()
GC.WaitForPendingFinalizers()

Regards
Prakash
0
 
LVL 10

Expert Comment

by:prakash_prk
ID: 12463015
http://www.scitech.se/memprofiler/Default.htm

Try this memory profiles to find the leaks, unremoved instanes .

Regards
Prakash

0
 
LVL 8

Assisted Solution

by:wguerram
wguerram earned 400 total points
ID: 12465361
Do you have public varaibles?

If there is an reference to the an object the GC won't collect the memory.

What type of application is yours? do you play alot with images? data?
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
LVL 12

Assisted Solution

by:farsight
farsight earned 400 total points
ID: 12500734
[nitpick]

>  Continuous addition to memory causes application to become slower

To me, this sounds like a conclusion rather than a fact.
Investigate what leads you to believe that additional memory used by your application is the CAUSE of it becoming slower.
0
 
LVL 5

Author Comment

by:fahimnxb
ID: 12613895
Ya data loaded in memory is too large, after destroying all objects , data sets adapter etc. And also calling
GC.Collect()
GC.WaitForPendingFinalizers()
memory is not recovered.

Eg
used memory before execution 100Mb
used memory after execution 450Mb
used memory after destroying all objects 350MB

dats the story.

Regards,
me

0
 
LVL 10

Expert Comment

by:prakash_prk
ID: 12613929

can you say which types of objects you have in your project ?

full objects list ?
0
 
LVL 12

Expert Comment

by:farsight
ID: 12616967
That's really not a problem.

GC.Collect is like cleaning your house.  It moves everything to the proper place, but it doesn't make your house smaller.
To get your house smaller, .NET will release some of your application's memory when the system becomes memory constrained.  But it there's plenty of memory, it will leave your house (your application) large.
0
 
LVL 8

Expert Comment

by:wguerram
ID: 12617055
But something is not good, since this is causing the application become slow.
0
 
LVL 5

Author Comment

by:fahimnxb
ID: 12621993
Exactly application is getting slow and GC.Collect is not collecting memory properly.

Objects are DataAdapter, SqlConnection, DataSet etc.


Regards,
Me
0
 
LVL 8

Expert Comment

by:wguerram
ID: 12624887
What version of visual studio are you using?

are you closing the connections when the forms are being closed or disposed?

how many forms do you have in your application?

have you noticed if an specific form that is causing the problem or all the forms cause the problem?
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: Jorge
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Suggested Courses
Course of the Month6 days, 22 hours left to enroll

594 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question