Re: Memory issues
| From: | Frank Heinrich | Date: | Tue, 14 Dec 2004 02:45:13 +0000 |
| Subject: | Re: Memory issues | ||
| References: | 1 2 3 4 5 6 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-5361@lists.php.net to get a copy of this message | ||
Regardng unexpected memory usage after Window/task interactions in MS Windows:
I have seen similar behavior under MS Windows (Win2k) with TCL/TK, so I don't think its anything specific to PHP-GTK. I think its part of the deep mystery of MS Windows Virtual Memory management.
I have a TCL/TK script that monitors external equipment and indicates status changes by changing text values in labels or changing images bound to labels or buttons. As it starts, it loads ("source" in tcl terms) many sub scripts, loads library packages, initializes GUI objects, etc. Once its running, it stays in a much smaller portion of the code until it detects a status change, and then it changes properties of some GUI objects. But in ongoing operation, it never executes as many paths/as much code as at startup. This app runs 24/7, unless some exteranl event causes a restart, or Windows finally runs out of virtual memory.
When it starts, it can use up to 17,000 K, as reported by Windows Task Manager.
The current Mem Usage seems to grow as it continues to run, even though I'm not creating any new objects. If I use the "-" button on the top Window to minimize and then restore the window, the current Mem Usage will shrink to around 2180 K. Peak Memory remains at its peak value, and overall the virutal memory load seems to stay high, but available physical memory seems to show it has recovered some space. As time goes by, current memory continues to grow slowly, but not consistently (some days sometimes as much as 40K in one day, sometimes zero growth for several days in a row, but typically 4 to 12 K. ).
So I think to myself, this is easy, just set a timer event in TCL and every 24 hours or so, minimize and restore the top window from TCL. Strangely, this has absolutely no effect on current Mem Usage, but manually clicking on the Windows title bar minimize button always seems to shrink current Mem Usage.
I've given up trying to understand exactly what is happening. My next step is to try invoking the minimize/restore methods on the window externally through a Windows GUI scripting tool, and if that doesn't work, then try a GUI click simulator to replay actual mouse clicks. Based on this email thread, rewriting in PHP-GTK doesn't seem like it would be fruitful.
--frank
Gonzalo Monzón wrote:
<snip>Hi to all, Thank you for the replies, Christian and Malk0, but I'd like to ear something about the second thing I was talking, and the really strange one. Let me explain it again so you can understand me: I already know about the memory issues, and so I use global arrays for setting all the widget stuff there. I always re-use the same variables on the global arrays for each unique window lets say it this way... when only I want to have an instance in memory -i.e. a simple dialog- I always instantiate it in the same var for minimizing memory waste. For top windows wich I want to have multiple instances, I store them in the global array too but adding to the item name plus an extra id. like window num. so each time I set it in "new" memory and each destroyed window doesn't release memory. Ok, that's the known behaviour with php4 - gtk1. As you said, we must accept it. Ok, but what I really don't know about is this: Once you have a php-gtk app running in memory, using ie. 16Mb memory -since here all is ok, you're working on the gui php application- but if then do I click on the taskbar and release the command line window from wich I've lauched previously the app -where the php app. does all the stdout-, some times at first or other times for second time, this causes two strangely change the memory usage of the app from 16Mb down to 200kb... ? Anyway the app continue running and all ok, but memory usage in the win2k task manager changes from 16MB to 200kb suddently releasing the command line... somebody knows why? Sorry my bad english... I hope now I've exposed this strange behaviour a bit better... Sincerely, Gonzalo Monzón