|
From: Waldemar B. <wb...@sa...> - 2011-03-21 18:57:38
|
Dnia poniedziałek, 21 marca 2011 o 10:04:43 Jeremy White napisał(a):
> Hi,
>
> > I use windows XP, Windows 7 and win32::GUI 1.06. Problem exists on the
> > both OS`s.
>
> What version of Perl are you using?
Perl 8.8 and Perl 10.0 (both ActiveState's) - results the same
>
> > It is not problem with win32::GUI but I experienced it just using the
> > module in my application.
> On my machine, your script hardly leaks at all (Win32::GUI 1.06, Perl
> 5.8.9). I would need to run your script for at least 100,000 iterations
> before memory becomes an issue? When you get strange colors it usually
> means your script is not freeing windows handles (which are
> created/destroyed automatically by win32::gui). Your script isn't leaking
> handles either.
Lets call it MAD (memory addressing drift) - i don't claim it is the memory
leak - I wrote the word "practicle".
I wrote another two cases: one in which Win32::GUI was replaced by DBD::Pg and
window by cennection: no MAD efect.
But next case is very inetersting: Win32::GUI replaced by Prima GUI - which is
independent of OS. Prima works in Windows and Linux. Well to the point! I have
no MAD efects, but... I have to add apart of these two undef commands another
one: $ch->{item}->close. This method closes windows (and - as it seems to me -
clears the memory too ) - no MAD.
The most interesting fact in this second case is the behaviour of Prima
windows when I comment the close method out. Then I see on the screen all the
windows created one after another! And - of course - MAD effect arises.
Mayby all the problem is that I do not use in Win32::GUI a similar method to
that ->close() ? But I can not find it though.
>
> > My question: Does anybode can show me how I could use the memory of
> > deleted objects again? Please look at the example: The address of the
> > object is going up and up... How to stop it? In the code I just delete
> > the object so it is obvious that the memmory is free for reusing.
> > Strange enough is the fact that the object which contains internal GUI
> > window objects got the same address. What is going on? I was searching
> > the Internet but not succeded - althoug they say in this area Perl
> > sucks. Maybe Perl is not good tool for 'really' big or long working
> > applications because of practical leak of memory?
>
> Perl uses a reference counting methodology for it's memory allocation and
> memory is only freed when the count gets to zero. If the count never gets
> to zero (because of a bug or design issue, such as using circular links)
> then memory will never be freed.
But what about my example? If it is bad desined problem I would be happy to
see the correction. Then I could correct my application.
> Perl is fine for large long running
> applications. In your example the small memory leak looks like a bug
> within Win32::GUI.
Maybe problem lies in a lack of the close function? I wonder if in pure
Win32::GUI (no Perl's module but in Windows dlls) there is such a close()
method? Maybe wrapping it to Perl Win32::GUI would help me?
This is not small problem to me. I have so heavy windows that sometimes it is
enaugh to open such a windows 10-15 time to get problem with MAD.
> It's likely that the issue you are having in your
> application is that you are storing references to Win32::GUI objects in
> different places so the reference count never gets to zero thus the object
> isn't destroyed.
But what about my example?
Jez, add a loop which adds to one window say 200 labels or textfields and check
what will happend. On my machine it needs 100-150 iterations to blow up. It is
not a "theoretical" example I have attached. I believe if I could fix the MAD
problem in the simple example then I could repair my application.
I suspect it is not problem with the amount of a memory. Perl - in the moment
of the MAT catastrophy - takes only 45-55 MBs. It's nothing!
> I've found the "big memory problems" are associated with
> leaking windows handles and GDI objects (open task manager and display
> these columns, if they keep increasing then you need to work out why).
I can't fine the windows handles and GDI objects in my task manager - where are
they?
Thank you Jez!
Regards
Waldemar
|