Re: Memory issues

From: Date: Thu, 16 Dec 2004 06:26:13 +0000
Subject: Re: Memory issues
References: 1 2 3 4 5 6 7  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-5366@lists.php.net to get a copy of this message
Malk0 wrote:
<>I've made some test and have the same strange things in winXP even using non php-gtk apps, as said by Frank i think that's 'just' another MS@#*&__ strange behaviour but not due to php malko
It's was just the most probable thing... windows its windows... If someone wants to read a bit, I will tell a little history of what i managed to do to solve some memory issues or multi-threading within a php-gtk app... Sorry my bad english in advance. In a php-gtk app. I recently made, there was the need to do more than one task at once, and to do these tasks automatically from the app -no user interaction for launching tasks or processes-. The tasks where things like generating html results based on templates, sending last result generated files to several web servers, refreshing results cache -for helping the result generation- stored on database as the data is being changed or added, etc... and having in mind that these tasks sometimes could have timeout errors, or due to heavy work load or communication faults some tasks could take more time to complete and so may be requested again from the main app before the last one finished and it needed to handle more than an instance per task concurrently but checking for timeouts to kill dead tasks... All this is because the app has to manage a sequence of changes in the database made by the "key" app. users or by other networked users sharing the same databases, and in real-time generate and broadcast all that data in a pre-processed way... at the best refresh rate possible... Some data needed two or more users to "col.laborate" in the shared data sheet so the results could be processed by some "key" users apps. who manage the complete data sheet and lauch some tasks other users dont to refresh cache and "broadcast" last generated results... it's something complex because some needs of the working scenario where the application is being used. So to manage all this -maybe there are better ways to do it but that's my way- I made an "app. process manager", an stand-alone php-gtk app. wich is visually something like any printer jobs manager but for app. tasks. This app. has an infinite main loop wich consists in looking for the existence of some files in some folders and act in consecuence. I've got a folder where the main app. places a file with the info of each task to be started, other for stopping a task, and other folders for the intermediate states -starting, running, completed, zombie, kill- so these last are managed by the process manager in interaction with each individual task, because each task has a timeout to refresh the "proc" file so the process manager can know about the process state and manage timeout. If timeout or stop event happens, the proc. manager sends the proc file to the kill folder and if the proc. does not respond, its killed using s.o. specific code. If a proc has to be started, the proc.manager launches it and places the proc file on starting... then the new process starts and it puts the file in "run" folder, and so on... I don't want to be too long, so the proc. manager and the app. work something similar to this... If I had managed to launch all the processes within the main app. It would not be possible to do next until the actual task is done... and on the other hand, each process loads about 20 or 30MB plus of memory... only released if you exit the program as we all know, So I solved this issue as i said running each process as an independent php instance, controlled by the proc. manager program. When a process is launched, the class and method to be executed is passed as a parameter and the "process framework" loads only the needed classes and execute the code... so i made some hacking to be able to lauch any metod of the main app. in a separate way, from another php intance, so the "process framework" I've done grants me to load and launch a concrete metod from any class of the same main app. -so any task can be done directly from the main app or like a background proc., of course, if its programmed for it...- Maybe it will sound something primitive..., but I needed to solve this issue in a couple of days so this was my quick way... I don't think the code could be in much help but the idea or concept to solve the memory or threading lacks of php-gtk... with some imagination there are lots of ways to hack about... and until php5 - gtk2 we will have to conform with this as someone of you said. Gonzalo Monzón

« previous php.gtk.general (#5366) next »