-2

This is a common problem with Windows. Over the years, it's something that I've noticed and it's really aggrevating me to the point where I just don't want to make apps anymore. So I've decided to try and fix it within my own apps.

When I minimize an app (for example, Visual Studio, Windows Explorer, Internet Explorer, Chrome, or any other app ever made) and leave it there for a while, there is a huge delay (of anywhere between 3 to 20 seconds) between the time I click the icon in the taskbar until the time it has reached WindowState.Normal again.

Why is this? Why doesn't Windows suspend processes when they are minimized on the Desktop? And how can I solve this problem within my own apps?

I have thought about using a Timer. Start the timer when I minimize my app, let it run for a while and say, after about 10-15 minutes of it being minimized, if it hasn't been restored yet, start releasing some resources in the hopes of freeing up some memory - which I assume would make the response time quicker so that it doesn't feel like I'm waiting in the ER when I try to un-minimize my app. But I am not sure if a Timer is the right way to deal with this problem, and I'm not even sure if this is the right solution. All I know is that I'm getting sick of this and I need to do something.

Has anybody dealt with this before? Are there any articles out there or is there MSDN documentation that addresses things like this?

How can I better manage resources in my apps so that they don't become so slow when inactive for a little while?

  • This problem is common to any app. Not just mine.

Edit: I'm not sure what to do. I always make good use of using() whenever something implements IDisposable, and I just don't know how else I can try and free up some resources or speed up the response times.

jay_t55
  • 11,362
  • 28
  • 103
  • 174
  • 1
    Is it your application causing the slow downs or another one? If it is idle and consuming resources.. you can guarantee it is a memory leak. – Simon Whitehead Jul 01 '13 at 04:37
  • 1
    I had a similar problem but that was quite opposite..see my [question](http://stackoverflow.com/questions/4863016/is-it-true-that-in-net-the-garbage-collector-gets-called-when-you-minimize-the) – Anirudha Jul 01 '13 at 04:42
  • Thank you @SimonWhitehead. Right now, the big guys use the most memory and CPU: Internet Explorer (358MB memory) with just 2 tabs open (google and SO). My apps at any point in time, are only about 1-5mb memory and 0.n% cpu in Task Manager, yet they are very slow to respond when restoring them from the taskbar. I thought it might be a memory leak, but I've even tried using a whole different set of apps (e.g. Replace IE with Chrome; Replace Outlook with webbased mail (inside chrome); Replace Evernote with Notepad. Just doesn't seem to matter what apps are open, it always happens. – jay_t55 Jul 01 '13 at 04:43
  • 1
    If your apps working set is stable and your PC isn't actually being crunched for resources.. I'd say it has nothing to do with your app at all. – Simon Whitehead Jul 01 '13 at 04:45
  • 1
    oops..the link to the answer was broken..here is the complete [article](http://www.cnblogs.com/Dah/archive/2006/11/25/572412.html) – Anirudha Jul 01 '13 at 05:02

1 Answers1

2

The symptomes you describe seem to indicate that your machine lacks physical memory. When you minimize an application and activate another, the minimized application has many of its memory pages swapped out to disk. When you activate back the application, pages belonging to other applications are swapped out to disk and the perviously swapped out pages belonging to the application you just activated are swapped into physical memory, taking a long time due to the relatively slowness of the hard drive. Solution: Add more RAM, it's relatively cheap. If your O.S. is 32 bit, you can go up to 4GB. If your O.S. is 64 bit, whatever your motherboard supports is the limit.

Tarik
  • 10,810
  • 2
  • 26
  • 40
  • 1
    I have Win8 64bit. I think it's time for an upgrade. Currently, this computer has 2GB of RAM and ah, I bought this computer like 2 or 3 years ago (maybe 4). I know that it's a long time ago but I don't use anymore apps than I did back then so I wasn't really expecting this, but thanks for the explanation. :) – jay_t55 Jul 01 '13 at 04:53
  • 1
    2 GB is very low by today's standards. Adding RAM should be enough and will avoid you purchasing another PC. The other thing you might consider is re-intalling the operating system. – Tarik Jul 01 '13 at 04:57
  • Tarik; Thanks heaps for that. I would normally just do a whole format of the drive and reinstall the OS but these days I am on a very limited-bandwidth internet plan (Mobile broadband) so having to re-download all my dev tools like Visual Studio, Eclipse, Android Studio and any other frameworks etc needed will be a huge cost for me so not really something I'm willing to do anymore unless absolutely necessary (I know adding more ram will also cost, but I believe that it's a more long-term solution/fix than wiping the drive and reinstalling). – jay_t55 Jul 01 '13 at 06:16