Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB.NET using SOOOOOO much memory!

Posted on 2004-04-23
4
Medium Priority
?
311 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 200 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month7 days, 19 hours left to enroll

824 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