Solved

VB.NET using SOOOOOO much memory!

Posted on 2004-04-23
4
303 Views
Last Modified: 2008-03-04
G'day everyone!

Hopefully this is an easy question that has an answer.

I have made 2 programs, adds a lot of data to a listview and another program which adds a lot of data to a database.

I look in the task manager, and my little program is using 30,000k and going up fast!

Why does VB.NET use SOOOO much memory, is there a way to flush memory or something?

Cheers :-)
0
Comment
Question by:undyshelts
  • 2
4 Comments
 
LVL 11

Expert Comment

by:rdrunner
ID: 10898293
This is the nature of .NET...

The memory is not "really used" but its just not "freed"...

.NET will release the memory if needed (.NET destroys Objects when it feels like it....) . Also make sure that you change the build mode... If you are still building the application in the Debug configuration then it will use extra memory.

Hope this helps...

0
 
LVL 11

Accepted Solution

by:
rdrunner earned 50 total points
ID: 10898341
P.s.:

To force a garbage collection you can use "collect" of the "system.GC" class...

0
 
LVL 4

Expert Comment

by:MajinLoki
ID: 10899624
I've noticed this as well with my application.  When you draw data from a database, your program stores all that data in memory until you release it.  My program is over 20,000 lines of code in 24 forms and 6 code modules.  This program only uses maybe 20,000K.  Why yours is using so much memory might be due to the type of database you are using.  I'm using a Microsoft SQL database.  Also, if you are using more than one form, I have found that disposing the forms when you are not using them(except for the starting form) will greatly reduce the resources used.  My program used to eat upwards of 80,000K until I implemented this strategy.  Using the GC.Collect has not helped my program, except when using Microsoft Excel reposrts that do not remain open.  the GC.Collect then helps to get rid of extra Excel objects that lie in memory.

My guessw is that because you are pulling a lot of data in and dealing with the database, it is that data that is your main absorber of memory.
0
 
LVL 41

Expert Comment

by:graye
ID: 10904901
Also, a technique to consider is to structure your application to deal with data in "chunks".

The data model for ADO.Net is inheirentally "disconnected"... which means everything in the database that you need in your program will be stored in memory.  To account for this, I've often written programs that read and write data in chunks (for example, after processing 10,000 records, I reconnect and write that "chunk" back to the database).

If your application isn't well suited to a disconnected model at all (yes, that's a distinct possibility), then don't use ADO.Net... use the good-old ADO model instead.  By the way... this is not heresy, the ADO model is still there for those applications that work better using a connected database.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

912 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now