473,379 Members | 1,174 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,379 software developers and data experts.

slow performance?

Hi all, I'm a completely newbie here. I'm having a problem. I've
programmed before in VB6 and such, and all the programs I've made run
fast. But .NET programs run very slowly. I use C# (for no particular
reason).

It's not the algorithms (that is, what the program * does *, that works
fine), but the UI responsiveness. This programs "hides" in the traybar
and sits there until the phone rings (It's a Caller ID program).

Everything works OK. The number gets identified correctly, the database
is looked up correctly, but the pop up window takes a LONG while to
appear (20 seconds sometimes!). While it's loading, the hard disk works
a lot.

The machine is an Athlon 2200 with 512MB ram and Windows XP Pro, so I
don't think it's a hardware problem. Windows task manager reports that
it's consuming about 18MB of RAM. Seems like too much, because it only
uses a couple of forms. The program is compiled "RELEASE" (not "debug")
in VS 2003. The .exe is 900k.

So, any ideas?

Hernán Freschi
Nov 16 '05 #1
10 2143
Only thing I could see making a form (and your form sounds simple) take a
long time to popup is the database round trip. Comment out the database
lookup and see how long your form takes to pop up. Do you have a large
dataset the query goes through? Are you transferring too much data back to
the client?

Chris
"Hernán Freschi" <hj********@hjf.com.ar> wrote in message
news:cu**********@amigo.idg.com.pl...
Hi all, I'm a completely newbie here. I'm having a problem. I've
programmed before in VB6 and such, and all the programs I've made run
fast. But .NET programs run very slowly. I use C# (for no particular
reason).

It's not the algorithms (that is, what the program * does *, that works
fine), but the UI responsiveness. This programs "hides" in the traybar and
sits there until the phone rings (It's a Caller ID program).

Everything works OK. The number gets identified correctly, the database is
looked up correctly, but the pop up window takes a LONG while to appear
(20 seconds sometimes!). While it's loading, the hard disk works a lot.

The machine is an Athlon 2200 with 512MB ram and Windows XP Pro, so I
don't think it's a hardware problem. Windows task manager reports that
it's consuming about 18MB of RAM. Seems like too much, because it only
uses a couple of forms. The program is compiled "RELEASE" (not "debug") in
VS 2003. The .exe is 900k.

So, any ideas?

Hernán Freschi

Nov 16 '05 #2
Chris, Master of All Things Insignificant wrote:
Only thing I could see making a form (and your form sounds simple) take a
long time to popup is the database round trip. Comment out the database
lookup and see how long your form takes to pop up. Do you have a large
dataset the query goes through? Are you transferring too much data back to
the client?

Chris

no, actually the database lookup starts after the form loads. that is:

1. phone rings
--->here's where the delay is
2. form loads. actually the form was already loaded but hidden, I show
it with this.Show();

3. mouse cursor to sandclock (by code)
message "Looking up database..." (SHOULD be shown but it doesn't, but
i'll deal with that later)

4. the database is looked up
(no delays here)
5. the number is finally displayed
6. mouse cursor to arrow

the database holds manually-entered numbers and it has less than 30, and
it's indexed and all (it's an access 2002 file).
i *think* the problem is that the program is too large for memory (18
megs) and windows swaps it (that would explain the disk activity).
so is there a way to reduce memory footprint?

hjf
Nov 16 '05 #3
How much memory is on the systems? When you call .Show, what triggers doing
the database lookup? Do you call Form.Show, then Form.LookupNumber? It you
rem out the code that does the actual lookup, does the form respond quickly
after the phone ring?

The message "Looking up database..." issue, just do a textbox.update or a
application.doevents to refresh the display.

Chris

"Hernán Freschi" <hj********@hjf.com.ar> wrote in message
news:cu*********@amigo.idg.com.pl...
Chris, Master of All Things Insignificant wrote:
Only thing I could see making a form (and your form sounds simple) take a
long time to popup is the database round trip. Comment out the database
lookup and see how long your form takes to pop up. Do you have a large
dataset the query goes through? Are you transferring too much data back
to the client?

Chris

no, actually the database lookup starts after the form loads. that is:

1. phone rings
--->here's where the delay is
2. form loads. actually the form was already loaded but hidden, I show it
with this.Show();

3. mouse cursor to sandclock (by code)
message "Looking up database..." (SHOULD be shown but it doesn't, but i'll
deal with that later)

4. the database is looked up
(no delays here)
5. the number is finally displayed
6. mouse cursor to arrow

the database holds manually-entered numbers and it has less than 30, and
it's indexed and all (it's an access 2002 file).
i *think* the problem is that the program is too large for memory (18
megs) and windows swaps it (that would explain the disk activity).
so is there a way to reduce memory footprint?

hjf

Nov 16 '05 #4
Chris, Master of All Things Insignificant wrote:
How much memory is on the systems? 512MB in one and 448 in another one.
When you call .Show, what triggers doing
the database lookup? Do you call Form.Show, then Form.LookupNumber? Exactly, that's why I don't think it's a database issue. The form should
be shown regardless of the delay of the database, and show the "looking
up data... etc" message.
It you
rem out the code that does the actual lookup, does the form respond quickly
after the phone ring? No, once the form has been loaded once, it works OK if I don't mess with
the machine (that is, if I don't do nothing, as in leaving it overnight).

It keeps running in the background, waiting for a RING from the modem.

So I work as usual with word/mozilla/messenger/etc. After a while it
seems like if windows unloads it from physical RAM because the program
is idle. Again, the program uses 18MB according to the Task Manager. Are
..NET programs supposed to eat up that much RAM? Even a simple "hello
world" program is *huge* for what I've tested.

After 2 or 3 hours of regular work on the PC, if the phone rings, that's
when the program gets slow. After that it works ok, but after a while
the same happens again.

The message "Looking up database..." issue, just do a textbox.update or a
application.doevents to refresh the display.

I'll try that, thanks

hjf
Nov 16 '05 #5

"Hernán Freschi" <hj********@hjf.com.ar> wrote in message
news:cu**********@amigo.idg.com.pl...
Chris, Master of All Things Insignificant wrote:
How much memory is on the systems? 512MB in one and 448 in another one.
When you call .Show, what triggers doing
the database lookup? Do you call Form.Show, then Form.LookupNumber?

Exactly, that's why I don't think it's a database issue. The form should
be shown regardless of the delay of the database, and show the "looking up
data... etc" message.

Not true. If you go straight into heavy processing after a Form.Show, you
are not going to see the form. Do an Application.Doevents() after the
Form.Show before doing any processing this will solve that problem, but the
form will be unresponsive until the processing is done. Threading is the
way to solve both issues.

It you
rem out the code that does the actual lookup, does the form respond
quickly after the phone ring? No, once the form has been loaded once, it works OK if I don't mess with
the machine (that is, if I don't do nothing, as in leaving it overnight).

I'm still not 100% sure this isn't a data issue. The form being loaded once
actually sounds like a data cacheing issue, which I have seen effect
performance just like you state. I know I suggested it once, but did you
try bypassing the actual call to the database?

It keeps running in the background, waiting for a RING from the modem.

So I work as usual with word/mozilla/messenger/etc. After a while it seems
like if windows unloads it from physical RAM because the program is idle.
Again, the program uses 18MB according to the Task Manager. Are .NET
programs supposed to eat up that much RAM? Even a simple "hello world"
program is *huge* for what I've tested. The memory displayed in Task Manager is not an accurate representation of
the memory used by .Net. I don't have any acticles to point you to off
hand, but google will help you find information about this.

After 2 or 3 hours of regular work on the PC, if the phone rings, that's
when the program gets slow. After that it works ok, but after a while the
same happens again.

The message "Looking up database..." issue, just do a textbox.update or a
application.doevents to refresh the display.

I'll try that, thanks

hjf


Chris
Nov 16 '05 #6
Chris, Master of All Things Insignificant wrote:
Not true. If you go straight into heavy processing after a Form.Show, you are not going to see the form. Do an Application.Doevents() after the
Form.Show before doing any processing this will solve that problem, but the
form will be unresponsive until the processing is done. Threading is the
way to solve both issues.
The Application.DoEvents() solved the form not showing "looking up
data...", thanks. I'll see if it also solves the slow loading issue.

I'm still not 100% sure this isn't a data issue. The form being loaded once
actually sounds like a data cacheing issue, which I have seen effect
performance just like you state. I know I suggested it once, but did you
try bypassing the actual call to the database?
Erm.. no :) I need some major modifications in the code to do that (YES
I know the whole point of objects is to avoid that kind of things ;)
I'll do better next time)
The memory displayed in Task Manager is not an accurate representation of
the memory used by .Net. I don't have any acticles to point you to off
hand, but google will help you find information about this.

Yes, I suppose the CLR and stuff eats up some memory, and that my actual
program is just a tiny fraction of that, right?

hjf
Nov 16 '05 #7

"Hernán Freschi" <hj********@hjf.com.ar> wrote in message news:cu**********@amigo.idg.com.pl...
After 2 or 3 hours of regular work on the PC, if the phone rings, that's
when the program gets slow. After that it works ok, but after a while
the same happens again.


I have seen this kind of behavior with some other applications that I use
(none of which are written in C#) . I suspect that Windows may be
swapping out parts of the application, and for some reason, it seems
to be extremely slow when swapping them back in (I haven't clocked
it but it feels like it would be faster to restart the application than wait
for the existing application window to update).

Here's an article I found that might shed some light. I doubt this is
authoritative but I haven't been able to find anything else on this
issue: http://suif.stanford.edu/pub/keepresident/

Hope this helps...

-- jeff
Nov 16 '05 #8
I think you are calling methods on the form from another thread. That
does slow down the application a lot (and results in exceptions in
Framework v2.0). Try using BeginInvoke(), that will also help you avoid
using DoEvents().

Regards
Senthil

Nov 16 '05 #9
Can you explain this a little bit anyway?

I have tried doing some things in a second program (NOT a .NET program) and
have seen some absurd delays when my .NET program is already loaded. I
wonder if I have triggered a GC pass when I tell the other program to go get
256 MB out of my 1 GB of RAM. One time, this operation takes 2 seconds,
another time it takes one minute. Program 2 REALLY likes physical memory,
and will ALWAYS do this operation in 2 seconds if nothing else is loaded.

With 1 GB of RAM, everything is always fast when my allocated memory (in
Task Manager) is well under 1 GB, but it is sometimes (not always) slow when
I pass this point. Having a clue what to expect of .NET memory handling
might help me.

Thanks!

Tad

"Chris, Master of All Things Insignificant" <chris@No_Spam_Please.com> wrote
in message news:Ok*************@TK2MSFTNGP14.phx.gbl...
The memory displayed in Task Manager is not an accurate representation of
the memory used by .Net. I don't have any acticles to point you to off
hand, but google will help you find information about this.

Nov 17 '05 #10
You need to do long calls separate from the UI so that it doesn't bog
down the thread that draws the screen. No matter what it is you think
it is to do w/ the Data source, trying using an IAsync call, or using
backgroundworker, and separate your UI code from the code that does the
work... you should see improvements in responsiveness.

~m.

Hernán Freschi wrote:
Hi all, I'm a completely newbie here. I'm having a problem. I've
programmed before in VB6 and such, and all the programs I've made run
fast. But .NET programs run very slowly. I use C# (for no particular
reason).

Nov 17 '05 #11

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

Similar topics

9
by: Neil | last post by:
I've been discussing here a SQL 7 view which scrolls slowly when linked to an Access 2000 MDB. After trying various things, I've distilled it down to the following: when the linked view has a...
8
by: BlueBall | last post by:
I am writing some kind of network testing tool and I have wrote the following code in ASP.NET with C# int size= 10048576; // around 10 MB data string buffer = ""; for (int j=1; j<=1024;...
11
by: ajou_king | last post by:
I was running some tests on my Win32 1GHZ processor to see how long it would take to transmit objects numerous times via TCP/IP using C# ..NET Remoting vs the C++ trustworthy method of binary...
3
by: jdipalmajr | last post by:
I am using a strongly typed dataset with a design time schema. I load data into the dataset tables from xml. The problem I am having is after the XML load. The first time I Add a row to a table...
3
by: Mario Soto | last post by:
Hi. i hava a postresql 7.4.2 in a production server. tha machine is a Pentium IV 2,6 GHZ AND 1 GB IN RAM with lINUX RH 9.0. The postresql.conf say: ...
52
by: frankgerlach | last post by:
>From my simple performance tests of SOAP it seems that it is about ten times slower than binary object request protocols such as RMI, IIOP or SimpleORB. Is this also YOUR experience ?
0
by: Andy_Khosravi | last post by:
I'm having a problem trying to optimize the performance of one of my A97 databases. I have very slow record navigation after a change I made to the table structure, and I'm not sure how best to...
9
by: dan | last post by:
within a loop i am building a sql insert statement to run against my (programatically created) mdb. it works but it seems unreasonably SLOW! Sorry, dont have the code here but the jist is very...
9
by: SAL | last post by:
I have an ASP.NET 2.0 app that takes about 17 seconds to load on first startup but then is very fast after that. As I understand it from some posts in June, this is caused by the loading of the App...
10
by: Arno R | last post by:
Hi all, So I bought a new laptop 10 days ago to test my apps with Vista. (home premium) Apparently Office 2007 is pre-installed. (a time limited but complete test version, no SP1) So I take the...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...

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.