473,811 Members | 3,152 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question on memory used by program

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
Jun 28 '06 #1
2 1923
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.

--
Bela Istok
MVP C#
"Asfar" <as**********@c ashmgmt.com> wrote in message
news:uW******** ******@TK2MSFTN GP04.phx.gbl...
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


Jun 28 '06 #2

Asfar wrote:
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

Jun 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1510
by: Milk | last post by:
Hi all, Can anyone help me to do this Question. Coz this is my first time study C++ language and my lecture want me to do this kind of program, i really don't have any ideal, or can send me some link is similar this program to me have a look, i already finish the MIPS part and the C Program that part also , but the simulator part is really hard for me~ pls help me
11
2318
by: Dan Elliott | last post by:
Hello all, I am writing a program which needs to run as quickly as possible, but holds a lot of data in memory (around 1GB for a usual run). Is this too much memory to even consider putting most/all of it on the stack? Does it matter? Any considerations I might take into account when deciding how to allocate the many data structures? By the way, the system will consist of a handful of very large data structures (primarily matrices...
2
6384
by: fb | last post by:
Hi everyone. I have the following code. It was a question out of C++ how to program. I get a warning about "possible unreachable code" in the RunCode() function, but I don't see any problem with it... I was hoping for a better way of exiting the case statements below. I used exit() for "divide by zero" and "invalid instruction". I can't get a try/catch to work. Probably from a lack of experience. I have a fairly strong C...
34
2183
by: FMorales | last post by:
-- I didn't notice anything about this specifically -- in the c.l.c. FAQ, nor could i get a strait answere -- from my copy of the C standard. Hopeing someone -- here could shed some light on it :)... 6.2.1 "If the declarator or type specifier that declares the identifier appears inside a block or within the list of parameter declarations in a function definition, the identifier has block scope, which terminates at the
4
2709
by: Chang Byun | last post by:
I have question about memory allocation. I have a trouble when I run a C program. My C program has several big double pointer(** var) variables to structure data like 4 by 5000000. It is supposed to calculate those varibles with different parameters repeatedly with same size of variables. When it is running, the first several run is fine But it uses more and more memory, is used up all the main memory and swap memory and is stop.
18
3717
by: jacob navia | last post by:
In C, we have read-only memory (const), read/write memory (normal data), and write only memory. Let's look at the third one in more detail. Write only memory is a piece of RAM that can only be written to, since its contents are undefined. The program is allocating a new piece of data, and the previous contents aren't relevant. This memory
73
4317
by: JoeC | last post by:
I am writing a game and I am having a challenge with my combat function. All I want to do is find out how to group pieces that are in the same space. There are two sides and all the units that are in the same space fight. I want to add up the attack factors and defending factors in the same space then figure out the odds so I can roll against an odds table. Basically each piece holds its own x and y loc. Here is what I have right...
7
6445
by: heddy | last post by:
I have an array of objects. When I use Array.Resize<T>(ref Object,int Newsize); and the newsize is smaller then what the array was previously, are the resources allocated to the objects that are now thown out of the array released properly by the CLI?
4
13892
by: pberent | last post by:
I am trying to run a c# program which loads very large arrays (total of about 1.2GB). I have 2GB of RAM on my machine and looking at task manager it doesnt look like it has all been used. I have set virtual memory (ie disk space to be used as RAM) to 3070MB. I have tested my RAM using a RAM testing utility and it seems fine. I am getting an out of memory error. I started by using visual c# 2002 but someone told me that it was buggy so I...
0
9730
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10651
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10392
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10403
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6893
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5555
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5693
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.