Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excessive Memory Usage in VB.Net

Status
Not open for further replies.

bigtimmin

MIS
Apr 12, 2005
125
US
I've notice that the programs that I have been writing in .Net uses almost twice as much memory as the ones I write in VB.6. I've made sure that I set all of the variables = nothing, no change. I tried implementing the Garbage Collector at the end of each sub/function, no change. When I manually minimize/restore the application the memory usage is almost cut in half. I've coded the application to minimize then restore itself automatically, but to no avail. Help!
 
.NET will use more memory than VB6 programs. One of the penalties of a large framework with a garbage-collected language.

BTW: you'll want to remove all your calls to GC.Collect(). The garbage collector does a good job of cleaning up short-term objects.

In order to minimize memory usage, allocate all your large data objects (> 85Kb) only once. The garbage collector doesn't run a compact cycle on them, so over time you can get some bloat if you new/dispose them a lot.

You'll also want to make sure you call .Dispose on any objects that support the IDisposable interface. Otherwise there's a chance that you'll be unnecessarily consuming scarce resources like file, database, and graphic handles.

To see where the large consumers are in your program, you can run perfmon.exe, and add some of the .net memory counters, and monitor it as you exercise your application.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top