Reducing Memory Usage When Storing Data In A Program - C#

Apr 18, 2012

I have an ArrayList that stores 100,000+ numbers inside of it. Each number is 10 digits in length or smaller. The program itself has data input into it, of which it loops through the user input to see if any of their numbers are already in the array using if ArrayList.Contains(userinput).

It would appear that when having an ArrayList of this size a LOT of memory is being used. Would there be a faster way to run this, E.g. Database or If TextFile.Contains(Line)?

View 3 Replies


ADVERTISEMENT

Reducing The Memory Usage?

Aug 30, 2009

I've been having complaints about my applications that they use to much memory.Is there a way to make them use less?

View 11 Replies

Thread And Memory Leaks - Memory Usage Jumps About 1000k And It Never Goes Back Down

Apr 17, 2011

I've noticed that every time I start a new thread in my program, the memory usage jumps about 1000k and it never goes back down. I have ensured that the thread is no longer running, and only one instance of my worker thread is ever running at a time. I am using ThreadPool.QueueUserWorkItem and ASyncOperation to get stuff done. The program starts using a Sub Main in a module that uses STAThread; I read that using STAThread instead of MTAThread makes it impossible for the Garbage Collector to get in and consider objects for garbage collection. However, when I change the STAThread to an MTAThread, the WebBrowser control in my frmMain cannot be instantiated.

I get this exception:

Code: An unhandled exception of type 'System.Threading.ThreadStateException' occurred in System.Windows.Forms.dll

Additional information: ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment. I do threading with the WebBrowser control, so will using MTAThread fix my problem? If so, how should I partition my code so that the WebBrowser control won't be affected by the above exception? I call the thread repeatedly with a timer (although only one instance ever runs at a time), and my program's memory usage starts at about 5000k and can jump to 300,000k+ depending on many times the thread needs to be called.

View 6 Replies

Memory Management - Reducing The Commit Size Of Application

Oct 15, 2009

I have an application which I've developed which queries Active Directory information and stores about 15 properties into a Datatable which is kept in memory. I need to decrease the amount of "Commit" memory it is setting aside. The application stays active in the system tray and allows for quick searching of information along with pictures for users. I have a class, which is able keep memory usage down pretty low. It runs on a timer every 10 seconds and listed below:

[Code]...

View 1 Replies

.net Memory Usage Functions?

Jun 6, 2010

i am a beginner in vb.net programming...started a project in it.Below is the breif project description.The application is to ensure the integrity of the files.Following are the majors things that i have to implement

1. To browse the files from the disk on runtime.initially i am just taking the database files so it's basically to connect with the MS access db files.

2.To apply the different hash and encryption algos on the file.

3.To store the results on the hard disk back.

4. To calulate the performance of each algo using some performance matrix.(TIME,MEMORY USAGE etc)

Now i am having problem in two things.First in runtime connectivity with MS access batabase..and secondly and the main problem is that i could'nt find any appropriate builtin function to calulate the processing TIME and the MEMORY usage.

View 3 Replies

VB Memory Usage Keeps Expanding?

Nov 22, 2011

Having a problem with the amount of memory being used going up and up, and expanding until there is no memory left. I'm using the GHeat.Net plugin to build images. Here is the full code:

Dim pm As New gheat.PointManager()
Dim g As Graphics
Dim startZoom As Integer = 2

[code].....

View 1 Replies

C# - Show Realtime Memory Usage In A .net App?

Jul 31, 2011

You can easily get the memory usage of the current process using workingset64 However I could not find any event like OnMemUsageChanged so I can display a little mem usage meter that displays live/real time the mem usage value. Updating in a timer every second can be done but looks inefficient. Is there anyway I can get an event or callback every time the mem usage changes ?

View 1 Replies

Form 1 Has Different Memory Usage At Different Times

Jul 1, 2009

i have two forms : Form1 and Form2..when i start application form 1 opens up, the memory usage is 10MB then i open form 2 and close form 1, the memory usage is 25MB.Again i close form2 and open form1, then the memory usage is 30MB.Why is this so that form 1 has different memory usage at different times...?

View 6 Replies

Holy Memory Usage Batman

Apr 28, 2010

so im about half way through with rebuilding my fav project in vs2008 (old code was in vb6) and today was a great milestone for me as i got to test out all its limbs (whats missing is still the brain). Most of the code is completely new, even tho it has roughly the same structure .net framework has replaced the majority of api calls and everything has been reoptimized for performance.Now when i ran the complete systems check i was pleased to find that everything functioned without fail and the entire thing took only third of the time then the equivalent on vb6. What was shocking however was the memory usage when i popped open task manager i saw it hogging up to 4gb of ram and then dropped like a stone to 100k, again up to 4gb and down to 100k like a themepark ride the vb6 version never went above 46k so this is odd for me. While it doesent cause any direct problems on this comp, im afraid it might hurt the performance on the end system im going to run it on.

View 6 Replies

How To Get Memory Usage Of Process In Windows

Jan 16, 2012

Is there any way I can get the memory usage for all processes currently running on a machine in vb.net?

View 1 Replies

Limit Memory Usage To A Thread?

Jun 7, 2012

I'm programming a windows services that is in charge of generate reports based to users request.for each user request I create a thread with next code:

hiloSolicitud = New Thread(AddressOf GenerarReporte)
hiloSolicitud.Start()

wherein GenerarReporte is a method that generate a report. I used threads because there are many users request.My problem is that when windows services has many users request the memory usage is to up 2 GB.that's the rest of memory possible, without count the memory for Operating System.In this case the windows services doesn't process any more request or reports because haven't more memory to work.so that when there are requests for large memory usage are processed but also allow the service of process windows of less use.I Want to limit memory usage for each thread.

View 7 Replies

VS 2008 Show App Memory Usage?

Sep 15, 2010

Is there a way to make an application show it's own memory usage?

View 9 Replies

VS 2010 : Storing Data In Txt File For Program Use?

Jun 22, 2011

In the program I'm working on, there is a 'sign-in' form that pops up for the user to enter first name, last name, and DOB. What I want to do is STORE that information in a text file for FUTURE use by the program (i.e. displaying a list of all previous users of the program).I already know how to use streamwriter to write text to a file, but I would like for the text file to be stored within the program files and also for a new user's data to be appended to that file every time.

Do I simply add the text file to the project files? When I do that, its path is 'My Documents'. How will that affect the program when I publish it? I guess I just don't yet understand what happens when the program is finished and published. The code for the 'Submit' button on the sign-in form is pasted below. At the bottom, I've put a comment to indicate where I want to store the data to a file.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim TxtBox() As String = {TextBox1.Text, TextBox2.Text, TextBox3.Text}
For i As Integer = 0 To 2
If TxtBox(i) = Nothing Then

[code]....

View 13 Replies

.net - Memory Usage In WPF Application - How To Track And Manage

Feb 12, 2012

I have a small-scale WPF application using VB.net as the code behind and I want to add certain features, but i'm concerned about performance.

1) My app interacts with a third party database to display "realtime" data to the user. My proposed method is to create a background worker to query a database every 30 seconds and display the data. I query about 2,000 records all long integer type, store them in a dataset, and then use LINQ to create subsets of observable collections which the WPF controls are bound to.

Is this too intensive? how much memory am i using for 2,000 records of long int? Is the background worker querying every 30 seconds too taxing? will it crash eventually? Will it interfere with the users other daily work (excel, email, etc)?

2) If an application is constantly reading/writing from text files can that somehow be a detriment to the user if they are doing day to day work? I want the app to read/write text files, but I don't want it to somehow interfere with something else the person is doing since this app will be more of a "run in the background check it when I need to" app.

3) Is there a way to quantify how taxing a certain block of code, variable storage, or data storage will be to the end user? What is acceptable?

4) I have several list(of t) that I use as "global" lists where I can hit them from any window in my application to display data. Is there a way to quantify how much memory these lists take up? The lists range from lists of integers to lists of variables with dozens of properties. Can I somehow quantify how taxing this is on the app or the end user?

View 2 Replies

Bitmaps And Pictureboxes, Memory Usage Off The Chart?

Apr 28, 2009

Bitmaps and Pictureboxes, memory usage off the chart!???????????

View 7 Replies

Code-generated Controls And Memory Usage

May 29, 2011

I have started with a small project in VB2008 Express which grew to a complex application. I have deployed the application recently discovering it is rather small, and the major issue is that code-generated controls (checkboxes, comboboxes, textboxes) are not displayed as during development. I have declared the code-generated controls in the declaration region, and there are about 250 controls. According to user selection some of the controls are added to a container panel. Now, I am concern that because I declare those as public (static?) variables, it uses much memory and causes the problem in the compiled application. Is that correct that static declared and code-generated controls uses much memory? How to avoid it ? I need the controls as public variables. Is it better to add all 250 controls on the form in designer mode, and use the property Visible (control.visible=True)?

View 1 Replies

Setup Performance Counters For CPU Usage And Memory Used?

Sep 23, 2010

I am trying to setup performance counters for CPU Usage and Memory Used.I would like a progress bar and a label to display the percentage.I have the below code and although it seems to be half working, there is something just not right.. The memory one seems to be working fine although the CPU one is acting strange.

[Code]...

View 2 Replies

VS 2010 Memory Reading / Offset Usage?

Sep 1, 2010

I saw some 'offsets' such as: 0x006E71A0and some that were like, Game.dll+8E336CI'd more so think the 0x006E71A0 and the Game.dll+8E336C are among the same format, so i'd like to use that.I have also read somewhere(this could be wrong) that the memory addresses formats are different between VB, C#, and C++.

View 2 Replies

Will Re-using Command Object Reduce Memory Usage

Mar 10, 2012

i wanna know for example if you have a few functions that actually creates a new sqlcommand in it and disposes them after use or is it better to have an sqlcommand at the main function and pass the sqlcommand in byref . and after using it. Juz clear the commandtext and the parameters.[code]

View 14 Replies

File I/O And Registry :: Storing External Data For Program?

Sep 12, 2008

I'm rewriting a legacy application in .NET. In the earlier version, I used a few control .INI files that could be edited by the advanced user to provide variation in certain program options. (The program also permitted override of these same variabes via menus and such.) I used the API functions to read the .INI files and rewrite them to alter the user's environment for subsequent runs.

View 19 Replies

VS 2010 - Storing Text Data In File For Program Use

Jun 28, 2011

Here is what I would like to do:
- Store string data from a 'sign in' form into a text file. This text file must be one that is saved even after the user exits the program. The text file must also be one that will stay with the program even after it is published (executable).
- Be able to write to/read from the file for purposes of displaying some or all of that data on a form.

I use an Application Setting to do this - of type 'Specialized String Collection'. I tried this, but for some reason I could not get it to work. It was a good idea, but I need to be able to SEE the data that has been saved, and with a setting it seems like that is not easily done. I've decided that I either need to use a simple text file or a 1-table database for this. I would prefer just a text file, but in either case, it needs to be part of the .exe when published.

I have added a text file to my project, but I am not sure if it will be "included" in the project when I publish it. The path of the file I've added is in 'My Documents', but in my code, I will have to specify the path in order to use Streamwriter. How will this affect the program when I publish it? I felt the need to make a new thread because on my last one we had been mainly talking about settings, and I've decided that isn't the best option for me.

View 1 Replies

Memory Usage Continues To Rise Until OOM Exception Occurs

Sep 24, 2010

I have a fairly complex application which makes use of an MS Access database. My application generates some 14million entries and inserts them after each generation, into the database. The app works perfectly without any bugs(that I am aware of) apart from one problem. If I run the app and let it run the full 14million odd data entries, the app crashes some way through and gives an Out of Memory exception.

I then loaded up TaskManager and notice that the memory usage increases by about 8-15Kb per second. I have done some reading and have tried using Dispose() to get rid of any objects finished with, I have tried building in release mode and the problem remains. I'm not even really sure if it is a memory leak or something else. I am using VS2010 and my application is running in .net 4.0.

View 1 Replies

Size Of The Class Affect The Memory Usage Of The Application?

Jan 27, 2010

Does a the size of the class affect the memory usage of the application? is it better to break big classes into smaller classes or just group them up into one big class.

View 2 Replies

VS 2010 : Setup Performance Counters For CPU Usage And Memory Used?

Sep 23, 2010

I am trying to setup performance counters for CPU Usage and Memory Used.I would like a progress bar and a label to display the percentage.I have the below code and although it seems to be half working, there is something just not right.. The memory one seems to be working fine although the CPU one is acting strange.

Shared perfTotalMemory As New ComputerInfo
Shared perfFreeMemory As New PerformanceCounter("Memory", "Available MBytes")
Shared perfProcessorTime As New PerformanceCounter("Processor", "% Processor Time", "_Total")

[code]....

View 2 Replies

VS 2010 HTTPWebRequests - Memory Usage Indefinitely Increasing?

Jun 23, 2011

I'm having an unusual problem that I've never had with WR's before. I have a very user-driven program that interacts with a server of mine through webrequests. Depending on what the user's doing, it could end up sending a dozen requests/minute. This has never been a problem before, but for some reason system memory usage increases and doesn't stop increasing, as if something is cluttering it up for every webrequest that is sent out.

Is there a known problem with WR's like this? Or is it just a random screw up? I can get my system back up and running smoothly.

View 5 Replies

VS 2010 Memory Usage Increases On Every Form Open?

Aug 26, 2010

I check the memory usage of my project from task manager, It always increases when I open forms but doesnt decrease when I close them. So the memory usage is getting bigger and bigger...

View 8 Replies

Storing On Physical Memory?

Oct 26, 2009

I've created an app that calculate calories that the user ate that day. They first enter breakfast, then lunch, then dinner, but the totals all open in one page and if they close that page, they lose their totals. How can i get the totals to stay on the physical memory until the user closes the whole app?

View 2 Replies

Gathering Physical Memory Usage Of A Started Process Tree

Mar 21, 2012

first of all, I'm not 100% sure this is the right forum to post this, as there seems ot be tones and tones of forum branches here, so if I'm not in the right location, i'm creating an IDE for a proamming language and I need a way to monitor the physical memmory usage of a process tree. I'm not talking about the WorkngSet64 of a process, but the WorkingSet64 of the process and any child process started by it.

[Code]...

View 7 Replies

Reduce The Memory Usage Forcing To Garbage Collector To Collect With The Method?

May 1, 2012

I have a problem with an application, in this case I have a windows services. its function is generate reports depending of demand of our users.In some cases the memory usage of my windows services is to 2 gb of RAM. I disposed all objects that my application use . but the memory usage doesn't low.I tried to reduce the memory usage forcing to garbage collector to Collect with the method "GC.Collect"but it's not recommend because uses many time of CPU.Surfing on the internet I found a method named "SetProcessWorkingSetSize" that free memory usage correctly. http:[url]....but some cases my windows services named sapdkadm_procesoestandarejecucion.exe has some error message in event viewer is the next:

Faulting application sapdkadm_procesoestandarejecucion.exe, version 1.0.0.0, stamp 4f908fef, faulting module kernel32.dll, version 5.2.3790.4480, stamp 49c51cdd, debug? 0, fault address 0x0000000000027ded.

The real problem is that when this happens my windows services restart

View 3 Replies

VB Memory Usage - Open The Form That Is Linked To Multiple Tables - It Jumps To 157 Mb?

Aug 1, 2011

I have an VB application that I developed in Visual Studio 2008. The back end is SQL. Application stores quite a bit of information and gets updated daily by users. It also connects to AD to get u/p, adds new accounts in AD and adds mailboxes. Users connect to it through Citrix. We noticed big spikes in memory usage. The executable itself is less than 5Mb; if I run it and it opens main form - memory usage jumps to about 19Mb, open a report - it jumps to 80 Mb. If I open the form that is linked to multiple tables - it jumps to 157 Mb. Once users start pulling new information in, update it and connect to AD or Exchange - it could jump to 250 Mb. Also noticed that if user with read only rights has application opened and idle - memory usage constantly changes with a pattern
like 17Mb - 19 Mb - 15 Mb - 17 Mb and so on. This user wasn't even using computer at the time. In general - what could cause such jumps in memory usage? What is the best way to prevent it? On the server we have Windows Server 2003 SE

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved