views:

100

answers:

3

Hello,

I am developing a software using C# 2.0 which uses about 200MB of memory and occasionally high CPU. The problem is, when i am leaving my machine idle for about 20-30 mins with the application running, after i come back and try to use the application, it freezes for about 2 mins, then becomes interactive.

Why does this happen? Is there any way to avoid this?

Thank you all.

Regards,

-Rakib

A: 

There is no way to answer such a question with the minimal information giving.

Some guesses:

  • Garbage Collection kicks in (nog very likely?)
  • Some system resources are accessed
  • UI Thread is blocking
Henri
This is not an answer. It could have been a comment though.
Nayan
Add to that .. paging and disk issues?
Peter M
A: 

You could try to use some .NET Profiler to figure out what part of code or thread is causing high CPU or memory usage

Hun1Ahpu
+1  A: 

Just a wild guess, but perhaps your app's memory pages are getting swapped out when its idle, and back in when you resume.

Either that or your UI thread is blocking on something. We'd need more details to really diagnose.

csauve
I think, you are right. It seems like memory pages are getting swapped. But how do I prevent this from happening?
Rakib Hasan
If memory pages are the problem, then this is OS problem. Maybe you can increase the page file size?
Nayan
@Nayan the page file is what its getting swapped *to*, which is what you want to avoid. I wouldn't think increasing its size would help (if this is truly the cause).@Rakib: could you give us info about how much free memory you have?
csauve
If its the OS problem, why doesn't it happen with other applications? Wouldn't increasing the page file size will increase the tendency to move my used memory to page file?
Rakib Hasan
@Collin: In such situation, I typically have about 1GB free memory.
Rakib Hasan
The amount of memory Rakib mentioned is about 200 MB, which is not small amount. You also understand that OS controls the loading and unloading of application independently. If you increase, page size, the OS has no tendency to put more data in pagefile. It's just all defined by the settings (if any, eg. Firefox has some setting like when you minimize, it reduces the RAM usage) and requirement of free RAM. In 20-30 idle mins, there could be some applications or even OS which need more free RAM to work upon something. Also, as Hans said, defragging also helps to speed up reading pagefile.
Nayan