473,396 Members | 1,846 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.

Over the time the CPU utilization starts increasing running my application

I have an application which listens to the serial port, processes the data and puts the extracted data on a large text box (which automatically scrolls to bottom).

The application even logs the same data in a text file (using FileStream - StreamWriter)

Over the time the CPU utilization starts increasing and after running it for 15 hrs its almost 100%.

I suspect the problem could be due to:
1.

Expand|Select|Wrap|Line Numbers
  1. txtTraffic.AppendText(sTextToWrite);
  2. txtTraffic.AppendText(Environment.NewLine);
  3. txtTraffic.SelectionStart = txtTraffic.Text.Length;
  4. txtTraffic.ScrollToCaret();
  5.  
these lines of code that executes every 250 mSec other than writing the same data onto a text file (after 15 hrs the log file size was 8 Meg)

2. FileStream - StreamWriter could be the problem although I highly doubt that
Mar 5 '10 #1
2 2078
EARNEST
128 100+
.Text += string; is very expensive (re-write the string from memory, back to memory). If you need to add a line only, use .AppendText(string);
---
So..
In 1hr your string would be 1mb. And you will need to transfer that meg every time you try to .Text += string;
In 2hrs 1mb+new size to transfer...
In 10hrs all the size...etc.
It would be very "heavy".
---
Mar 5 '10 #2
tlhintoq
3,525 Expert 2GB
I see this one a lot.
Instead of a Textbox and appending the text (as mentioned is expensive), using a ListView, set to Details. Then add to it it's .Items collection. Now you can pick any entry you want (if you need to) by selecting myListView.Items[15] or whatever.

The other good thing about this is you can delete off items as the ListView fills up.

if (ListView.Items.Count > 500) ListVIew.Item.RemoveAt(0);

So every time you add, you check, and remove the oldest items as needed.

Also, with your log file: Are you keeping it open for 15 hours? Is the entire file therefore in memory the entire time? If so... Bad. Very easy for the file to get corrupted if the PC shuts down without closing it properly.
Just us a File.Append to open the file, add to it, close it.
Mar 5 '10 #3

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

Similar topics

4
by: Anks | last post by:
hi I am testing my applet to servlet communication program using appletviewer. as soon as i start the applet the cpu utilization reaches to 100%.I am using apache tomcat 4.1 application...
54
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
9
by: Tom Dacon | last post by:
I have a little desktop application (it happens to be a Windows Forms analog clock) that's written in VB.Net (2003). I placed a shortcut in my Startup program group to start it up when I log on. I...
77
by: Charles Law | last post by:
Hi guys I have a time critical process, running on a worker thread. By "time critical", I mean that certain parts of the process must be completed in a specific time frame. The time when the...
1
by: Simon Sadedin | last post by:
Folks, I’m hoping someone can give me some pointers to resolving an issue with postgres and it’s ability to utilize multiple CPUs effectively. The issue is that no matter how much query...
1
by: jay | last post by:
Greetings I have a C# windows service that creates several application domains. Each app domain has it's own programs running, doing their own thing, independent of each other. Recently,...
5
by: Benny | last post by:
I am having a memory problem with my application. Plain and simple all the program does is runs through a bunch of images and prints them to a PCL Printer. The first part of the application that I...
11
by: Ajith Menon | last post by:
I have created a windows application in which the form needs to be resized on the MouseMove event. The windows resize function takes a lot of CPU cycles. And as the resize function is called on the...
0
by: spider007 | last post by:
i want to find out the CPU Utilization per application in my DB. The problem is that we have OLTP and DSS transactions happening on the same server and we are not able to convince the client that the...
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...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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...
0
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,...

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.