473,396 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Quickie Memory Consumption Q ?

Samishii23
246 100+
Lets say I have 30 variables, int, string mostly, or more...

Would it be better for me to make 30 separate instances of a variable. Or an array with [30] slots?
Dec 3 '09 #1
7 1537
tlhintoq
3,525 Expert 2GB
What do you define as "better"?
Faster response...
More human-readable code...
Smaller memory footprint...
Ease of coding...

For 30 variables of any standard type such as int, string and so on...
It really won't matter. It's not like the days of the Commodore-64 where you only had 64 *K* of memory.

If you had 30,000 it might be a different story.
Hey, there is a good test...
Programmatically generate 30,000 ints and strings and give them all values and see how much memory that takes.
Then create a couple arrays of 30,000 and assign them values and see how much that takes.

Whatever the difference in memory usage is for those two tests... You application will see 1/1000th of that difference.
Dec 3 '09 #2
Samishii23
246 100+
I am worried about amount of memory used mostly. Speed of the application isn't really my big worry.

I thought it may have been more of a difference then what you describe.
Dec 3 '09 #3
Minion
108 Expert 100+
As far as memory consumption goes it's not tied so much to the number fo variables (unless your getting into the thousands), but rather the content of the application. If you have a large number of forms or a dataset that must be kept in memory this will eat up memory far faster than variable declaration.
Dec 3 '09 #4
alexis4
113 100+
If they are logically connected, then a class or a structure would be fine. If not, then you should keep them separate. Still you can store them in a class, but this would make your code more difficult to read. If we are talking about same variables (for example 5 pictureBoxes), then a class array is recommended for my part, because if later on you decide that for example you need two buttons for each pictureBox, it would be uncomfortable to have 15 event handlers in one form instead of three! Besides that, you do not know if later on the 5 boxes become 10. So one important factor is to have a stretchable code, especially in bigger projects.
Dec 3 '09 #5
Samishii23
246 100+
Well, basicly my application is going to be heavily string based data, not that that is uncommon, its just I'm still brainstorming ideas on how to store, and retrieve the data ( the reason for the post ). Also will be using alot of images.
Dec 4 '09 #6
PRR
750 Expert 512MB
What exactly are the variables? int and strings? I guess you are facing a design issue here. Try a OO (object oriented) approach here. Maybe group together strings and int that are related in a structure or class. Have a main class that has objects of the other classes and structures. Also you can look into interface and inheritance. This approach will make your code less complex and easy to read, maintain and understand.
Dec 4 '09 #7
Samishii23
246 100+
Well. The very first way I was storing the data was in a class. Each data set had its own class. To give you an idea of what I'm working with, I have 10 classes. ATM, I don't have this data set fully complete, and .cs file is 242 KB large. Thats just the data. Not functions or anything. This the general layout of the variables...

Expand|Select|Wrap|Line Numbers
  1. public class cData1 {
  2. // 3 of each the next variables
  3. public readonly int dPts[44];
  4. public readonly string dTitle[44];
  5. public readonly string dIcon[44];
  6. public readonly string dDisc[44][];
  7. }
I want to put all the data into XML format, though the XML portion of C# is... Kinda bloated. Heh.
Dec 4 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Andy | last post by:
Along with many others I've noticed the large amount of memory that can be taken up by the aspnet_wp.exe. I've found that I can better control and limit this memory consumption by including a...
1
by: anandav2001 | last post by:
Hello developers, I have created an executable(system tray application) in VS.net 2003 using VB.net. My app was taking 30 MB memory(since some web services call are there which happens for each...
7
by: Salvador | last post by:
Hi, I am using WMI to gather information about different computers (using win2K and win 2K3), checking common classes and also WMI load balance. My application runs every 1 minute and reports...
8
by: Raja Gregory | last post by:
Hi All, I have developed a server application in C#. While running this application, it is not running more than 30 minutes due to memory leak. Could you tell me what will be the problem?
9
by: Adam Right | last post by:
Hi, Anyone suffers from the high memory usage of C# in windows applications? Is there a solution for that problem? Thanks...
12
by: Tony | last post by:
Hi expert, I installed DB2 v8.2 server on Solaris 9 box. When I connect to DB2 using control centre or other applications(except command line), around 12 db2sysc processes pop up and each one...
1
by: buu | last post by:
It's strange to me, but, create a dictionary and fill it with 1 mil. of some objects. then, see the memory consumption (arised, of course). then, clean the dictionary.... memory consumption is...
2
by: Jonas Maurus | last post by:
Hello everybody, I'm pondering the following problem: I want to write a Python program that receives messages via SMTP and stores them in a dict or an array. For my purposes it would be...
10
by: deciacco | last post by:
I'm writing a command line utility to move some files. I'm dealing with thousands of files and I was wondering if anyone had any suggestions. This is what I have currently: $arrayVirtualFile =...
17
by: Cesar | last post by:
Hello people. I'm having a Winform app that contains a webbrowser control that keeps navigating from one page to another permanentrly to make some tests. The problem I'm having is that after a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.