Solved

VB.NET using SOOOOOO much memory!

Posted on 2004-04-23
4
302 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

11 Experts available now in Live!

Get 1:1 Help Now