Solved

VB.NET using SOOOOOO much memory!

Posted on 2004-04-23
4
308 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

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 …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

632 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