Groups | Blog | Home
all groups > dotnet performance > september 2004 >

dotnet performance : Application gets slower and slower



Igor Anic
9/16/2004 8:57:31 PM
I'm going to review an application written in VB.NET. The problem is
that during using application (after few hours) it gets slower and
slower. After my first impression (I look at it for 5 minutes) is is
not, a memory problem. It is a database intensive application but it is
not the server problem neither (applications on other machines work
normally).
Does anyone have quick tip or experience with similar problem.

Thanks,
Sriram Krishnan
9/18/2004 9:25:45 AM
Use CLR Profiler and see where your memory is going. If the app is not
getting slower due to memory usage, then attach a profiler to it and see
where the time is being eaten up

--
Sriram Krishnan
Microsoft Student Ambassador
http://www.dotnetjunkies.com/weblog/sriram


[quoted text, click to view]

Marcel van den Hof
9/18/2004 2:12:36 PM
My first impression is that the application suffers from memory retention
(references that are not freed up, because the objects holding these
references do not get GC). I would suggest you use a profiler like CLR
Profiler or Scitech's .NET memory profiler. Let us know how it works out.

Good luck.

Lloyd Dupont
9/20/2004 11:56:06 AM
a tricky memory issue that people often don't pay attention to (granted it's
trick) is event.
if you register for an event in an object which is valid, you won't be GC.

it's why it's often a good idea to provide a Dispose() method (even in fully
managed object)(to be explicitely called), at least to remove event
listeners.


[quoted text, click to view]

Igor Anic
9/21/2004 10:58:21 AM
[quoted text, click to view]

My first action was to turn on .Net Performance counter. According to
the results I think that there is no memory problem. Both .Net memory (#
Bytes in all Heaps, Large object Heaps size,..) and Process memory
(Private Bytes) stay constant during program running.
What I found interesting is that application raises large number of
exceptions (# of Excepts Thrown) and that the value constantly raises
(few thousand per hour).
Further investigation of that exceptions shows that they are raised
somewhere in Datagrid control.
Changing the filter of the dataview registers exceptions in .Net
counters. We could not catch that exceptions in application, it is
handled somewhere.
Could that be the slowdown problem?
Any Experience?

Thanks,
Bob Grommes
9/21/2004 1:18:10 PM
Igor,

Catching an exception is expensive. My guess is that someplace in the event
code someone has coded try/catch blocks to catch what is probably a fairly
"unexceptional" exception. This code is relying on exceptions to react to
certain conditions that could probably be tested in advance to avoid the
error condition in the first place.

I would search for catch blocks in any source code file that references a
Datagrid and review those for appropriateness.

--Bob

[quoted text, click to view]

Bob Grommes
9/21/2004 3:31:23 PM
Fair enough, but what beyond whatever overhead there is to a catch, I would
still examine what is being done by the catch block itself. And catching
exceptions in a tight loop or a frequently called event still strikes me as
an inelegant and potentially defective design.

--Bob

[quoted text, click to view]

Jon Skeet [C# MVP]
9/21/2004 9:59:46 PM
[quoted text, click to view]

Catching an exception isn't *that* expensive. Igor says that the number
of exceptions thrown rises by a few thousand per hour. My laptop can
throw and catch a hundred thousand exceptions per *second*.

Exceptions are often held up as performance monsters, but they're
really not. They're expensive compared with "no-op" code, but not
nearly as expensive as they're often made out to be. There are much
better reasons to avoid exceptions in non-exceptional situations.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
Jon Skeet [C# MVP]
9/22/2004 8:19:23 AM
[quoted text, click to view]

True - but I'd expect that that handling would need to be done if the
error condition was tested in advance as you suggested.

[quoted text, click to view]

Certainly, but performance is not (IMO) the principal reason for that,
unless it really *is* a tight loop. (There's no indication that that's
the case here, as only a few thousand exceptions are thrown.) Reasons
of maintenance and readability are higher on my priority list.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
Russell Moss
9/28/2004 7:53:04 AM
Igor,

One thing that occurred to me is that you could be registering an event
handler repeatedly. I'm not a VB.NET programmer so someone can give you more
guidance, but (in C#) you might be doing something like :

private void SomeFunction( ... )
{
myvar.OnSomeEvent += new MyEventHandler(...) ;
}

Another 'related' possibility is a Timer event that you create over and over
but never destroy.

Russell


[quoted text, click to view]
AddThis Social Bookmark Button