Gonzalo MC escribió:
Jochem Maas escribió:
Gonzalo MC wrote:
Hi Jochem,
Thank you very much for your reply!
no problem :-)
Your reply lend me this morning to had a look again at the code, and
I have solved more than half of the trouble caused by a leak on a
PhpGtk function! :-)
Sorry for the more long reply than it should be, but I hope you'll
have the time to read it. Unfortunately, I have not fount an
easyier way to explain the thing and get to something with meaning.
well I read it, but I didn't understand all of it. not to worry.
as a sidenote - reading about the objects (some gtk style wotsit) in
your codebase
I got the impression that the unfreed memory is possibly [mostly] to
do with those -
my memory usage problems are always to do with objects (remember in
php that
object variables basically work semantically like scalar values as
opposed to php5
where object variables are handles to objectsa and effectively[,
always,] work like
[php] references of normal variables)
I'd concentrate on getting those objects 'tuned' - generous but
highly controlled
use of the '&' symbol to force objects to be passed by reference
where possible/relevant
(e.g. when using the 'new MyObject;' syntax) can also help.
...
Hi again,
Yeah you're right the memory usage problems always have to do with
objects on php4, and using '&' is of great help, but in my case, with
the actual implementation, I've tested almost all the ways in the
exact points where data is handled, and fount no reliable way for
reusing reserved memory from the interpreter other than going to
functional style programming and avoid setting object properties, etc.
Fortunately, my application almost does not create any object other
than in the beginning/initialization of and for the GUI, for what I
have some helper classes to abstract interfaces, but they are all
instantiated on the program startup and the only objects I do create
"on the run time" are perhaps the new style copyes according to each
new insert or update to the existing widgets on screen, and they are
almost all referenced byref using & when adding pixmaps and such -
note the $astyle = gtk::rc_get_style($ctree); line per example is only
done once before all items loop and it does not take any memory, not
the case when creating or transfering a widget from a way to another
where the & really matters- but the trouble is when you call for each
node in the loop to the $astyle->copy(); method per example-.
All the data I generate, update or read are arrays with numeric or
alfanumeric keys, in wich I place another array with some alfanumeric
keys.
The data is generated by an object. It is stored in global variables,
and some references to these are keept on that or other object
properties, when processing or updating data based on the last data
received. I think the trick was to put these references to the global
array items, outside these objects, in the global namespace too, but
only worked when the data was processed from plain functions,
-actually the processing work is done from a class instance that
extends another root class-.
Maybe it haves something to do with the processing and gui update
loops, fired by gtk_timeout's from inside objects calling object
methods... Maybe on refactoring, now I have more knowledge about whats
going on, I will notice of.
I expect to get soon the time needed to refactor again this and I'll
post the concrete workaround for my case, perhaps could help somebody
to get a more clear idea of ways to avoid these memory usage issues on
php4 / PhpGtk1. Until then, I'll though a good plan so when
refactoring going in stages of "migration" so I could really find the
real nature of the issue -object properties are references to some
globals / processing of globals fired by gtk_timeouts calling object
methods by reference / whatever it could be-.
And thank you again for your response. I know perhaps it does not
matter much but... :-) thats it.
Best Regards,
Gonzalo.
Sorry but I forget to say that when loading data from a file, -so a big
process is done without updating the GUI where is the only place objects
are perhaps more relevant- the program gets a lots of megs of ram, only
with the processing of the global arrays from within an object... So it
has to do with the processing of that data from an object.
For a moment I though the data I'd willing to reuse is maybe leak in
some place... not in the process itself, but on the other way I do
remember clearly how I did get improved this part of the process
-loading from file, processing, and finally do a GUI update with
results, and do it again with another file, and have only a small amount
extra of memory used- while doing it from an object lends to a lot of
memory not being reused -or being really leak-.
Regards,
Gonzalo
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php