Question on memory used by program

  • Thread starter Thread starter Asfar
  • Start date Start date
A

Asfar

Hi,

I have a VS2005 windows program written in c#.
In this program I have an array list which stores many DataTable's. When I
first run the pogram the arraylist is loaded with datatables. At this point
when the see the memory used by the program in task manager it is 135,654K.
Now when I minimize the application the memory goes down to 1,456K. Again
when I maximize the program and start using different menu options the
memory used remains around 18,000K - 20,000K.

My question is the huge memory utilized by the program initially is because
of GC has not run or I am using lot of memory in my application?
Will the memory used by the application reduce if I change my program from
using an ArrayList of datatable to a single datatable but having data from
all the rows of each datatable in array list?
Will the memory used by the application further reduce if i used an
arraylist and store values as objects of custom classes instead of using
DataTable?

I am using an ArrayList of DataTables because the information from each
datatable is displayed in a DataGridView. At any given time only one
DataTable from the list is displayed based on the user selection. Right now
in the my ArrayList I have 37,000 DataTables and this is not constant and
will increase or decrease.

What would be the best design approach ? Anyone any ideas?

Thanks,
-Asfar
 
Ok, it's normal when you minimize the application, this frees some not in
use memory, because the GC not run all the time only when needed (ex. you
don't have more free memory).
I recommend you, to load the information only in the time the user need
that. In all test I have done, the user not need all the information all the
time, I recommend you to use on demand data load. And no load all the data
at application start.
 
Asfar said:
Hi,

I have a VS2005 windows program written in c#.
In this program I have an array list which stores many DataTable's. When I
first run the pogram the arraylist is loaded with datatables. At this point
when the see the memory used by the program in task manager it is 135,654K.
Now when I minimize the application the memory goes down to 1,456K. Again
when I maximize the program and start using different menu options the
memory used remains around 18,000K - 20,000K.

The task manager "memory" column displays the working set of your
process, which is basically useless to measure the memory footprint of
your app, since the working set is trimmed when the main window is
minimized (as you've experimented), when there is heavy memory pressure
from other processes, etc...

Instead, use perfmon to monitor the "Private Bytes" counter for your
process : this is a much better measurement of your app consumption.
There are also .NET heap counters that will help you. Once you've got a
correct idea of the memory behaviour of your app, come back if you have
more questions

Arnaud
MVP - VC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top