batkins has asked for the wisdom of the Perl Monks concerning the following question:

I've noticed something rather peculiar about minimizing Tk windows. My script uses about 4028K RAM when it starts on my WinXPPro machine. If i minimize the window, its usage drops to around 456K. But the really weird thing is that the usage goes up to 944K after I restore the window. I have noticed the same behavior with all of my Tk scripts.

I don't quite understand how this is happening, but it seems like this would allow my Tk programs to use less memory. I tried making my program minimize and then maximize on startup (using iconify() and deiconify()), but the memory phenomenon did not occur.

Does anyone know why this happens, or, more importantly, how it can be used to reduce the total RAM usage of Tk apps?

Thanks, monks!

  • Comment on really weird minimizing behavior with Tk

Replies are listed 'Best First'.
Re: really weird minimizing behavior with Tk
by pfaut (Priest) on Jan 31, 2003 at 02:50 UTC

    This would appear to be a new annoying behaviour of windows as of about Windows 2000 (at least I never noticed it before then). I've noticed that Netscape/Mozilla get their memory usage trimmed down when minimized as well as some other applications I've used. It seems that Windows thinks you are minimizing applications because you are not using them and attempts to free up some resources while the app is minimized by trimming its working set. If anyone knows of any registry setting that would disable this behaviour, I would love to know about it since I usually minimize things just to get them off the screen to make room for other things.

    --- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';
Re: really weird minimizing behavior with Tk
by Anonymous Monk on Jan 31, 2003 at 04:13 UTC
    I don't know the full details, but Windows does that for any program...try it yourself: open task manager and select performance tab, now minimize and then maximize any program window...you'll see mem usage go down and then up. chris_piechowicz@hotmail.com