> Finding the GDI objects number was crucial. It was written 10000 and maximum -
> according Microsoft is 65,536 (for XP). The number is written in registry
> under the key:
> NT\CurrentVersion\Windows\GDIProcessHandleQuota

Vista and Windows 7 have larger default values, but you really need to work out why you are using so many GDI objects. It shouldn't be that high...

> However problem of reusing undefined objects remains. Now I know that it is not
> problem with the memory but with deleting graphical objects.
> Jez I wonder what is a differences between your and my installations of
> Win32::GUI (and windows) that I have problem with GDI objects number (objects
> are not deleted) and you not?

I do a lot of GDI drawing and have no leaking GDI objects (I hope!). As long as the object (pen, font etc) goes out of scope after you've used it then the GDI handle will be freed. For example, say you do something like this (sudo code):

       my $pen = new Win32::GUI::Pen(
            -color => [ rand()*255, rand()*255, rand()*255 ], 
            -width => rand()*5,
    %pens{$pen} = $pen;
   #do some drawing
   undef $pen;

The pen is stored in a global hash, and therefore will never be deleted. 

I also find creating and destroying GDI objects has performance implications (Windows not perl) so I tend to store pens, brushes, fonts in objects so I can just reuse them. You should be able to reuse GDI objects across windows (as long as the window and object were created in the same thread).

> I have checked Perl 5.8.9(829) from 21-01-2011 08:00:46.
> I use also Prima and I do not find version for Perl 5.10 - I have for 5.12 (the
> newest). Is it save to install Win32::GUI from Perl 5.10 in Perl 5.12?

Personally I've always had 'issues' with Perl 5.10.x which is why I have stuck with with 5.8.x - I have been meaning to try 5.12 but have never got round to it.