Solved

500pts: CPU Utilization is really high in my app

Posted on 2006-10-30
3
199 Views
Last Modified: 2010-04-16
Hi there,

I wonder if anyone can help, I am having some major issues with CPU utilization...

I have an app and basically it creates 24 reference types (objects) and stores them in a hashtable... at this point utiilization is pratically 0

The next day I clear out the hashtable which I presume will destroy the references as when i added them they they were local reference variables   to  a class. I use the method .Clear and then i recreate local variables of the 24 reference types (classes) and readd them to the Existing hashtable which of course is empty now...

At some point during this period .. the utilization creeps up to above 25%,,.,.

Should I be doing .dispose or somehting??

I really hope somebody can help, i am totally lost as to why it would be happening...

Thanks in advance

Ian

0
Comment
Question by:ianinspain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 6

Accepted Solution

by:
der_jth earned 250 total points
ID: 17835399
Memory leakage per se will not cause CPU utilization to rise. If you release all the resources to your objects, they will be collected. Sometimes you accidentally leave refs hanging around, but that doesn't cause a constant CPU pressure. Dispose will speed up releasing external resources (DB connections or similar ones), but for memory-only objects it isn't necessary.

I suggest you look for endless (or nearly so) loops. When the application is taking 25% CPU, attach a debugger and see where the code is. Helping you much more than that is pretty much impossible without seeing your source code.

0
 
LVL 6

Assisted Solution

by:wbradney
wbradney earned 250 total points
ID: 17851496
The 25% figure is suspicious.
Is it always 25%?
Do you have a quad processor machine (or a dual-dual-core or dual HT machine)?
If so you're almost certainly looking at a tight-loop, as der_jth suggests, but it may not even be in your code. I've found tight-loops in Windows Forms UIs that bind user-defined types to components. If your type doesn't correctly report Equals and GetHashCode results, some components can constantly invalidate/revalidate areas of the screen because they think that the value of the bound variable has changed.
0
 

Author Comment

by:ianinspain
ID: 17864872
thanks both... yes it was a loop... thanks... for that..

ian
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question