Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB.NET using SOOOOOO much memory!

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

722 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