Author Topic: Whipping Top  (Read 1981 times)

0 Members and 2 Guests are viewing this topic.

Peter

  • Guest
Whipping Top
« on: January 14, 2014, 01:55:06 PM »
Deleted
« Last Edit: April 25, 2015, 03:18:59 AM by Peter »

Mike Lobanovsky

  • Guest
Re: Whipping Top
« Reply #1 on: January 14, 2014, 02:54:20 PM »
Yes Peter,

Looks very nice but unfortunately leaks GDI objects like hell (best seen in Task Manager, process gxo2.exe, with GDI Objects column turned on) when you drag the window partially beyond screen borders and back into full view.

That's caused by a (obviously copy-paste) typo in your DeleteObject() calls. Should be:
Code: [Select]
.................
     SelectObject hdc,oBrush
     DeleteObject bBrush
     DeleteObject yBrush
     DeleteObject rBrush
.................

I would also recommend releasing the app window's hDC explicitly before destruction:
Code: [Select]
.................
Else iF wMsg=WM_Destroy
   ReleaseDC hwnd, hdc
   PostQuitMessage 0
................

Mike Lobanovsky

  • Guest
Re: Whipping Top
« Reply #2 on: January 14, 2014, 11:18:34 PM »
Hello Peter,

gxo2.exe is Oxygen's runtime process module that runs your script in a JIT mode when you start it from your SciTE with F5 or Tools->Go menu without precompilation on disk. When run as a precompiled (standalone) executable, the Whipping Top script's process will have whatever name you used to compile your executable under.

In either case, you will see the number of undeleted gdi objects in the system memory swiftly grow by hundreds as you drag the app window partially beyond your screen's border and back several times. That's the easiest way to enforce your application to redraw its window. Make absolutely sure to switch on the GDI Objects column in your Task Manager beforehand. This column is off (invisible) on default. My fixes keep the number of gdi objects constant at approx. 32 or 33 under my XP Sp3 I'm currently working in. Your Win'7 may show a different number of gdi objects for the same task but it should be constant. If it is not, your GUI program is leaking memory.

By all means, the DeleteObject() WinAPI expects only one argument which is the gdi object's handle. Any other decision will be a bug and will cause gdi memory leakage.

Hope this helps. :)

Mike Lobanovsky

  • Guest
Re: Whipping Top
« Reply #3 on: January 15, 2014, 12:01:13 PM »
Hi Peter,

You didn't respond to the DeleteObject() issue, why? Still using hWnd in there? If you're not prepared to discuss and fix your, er, questionable design solutions then why publish at all? I wasn't talking about how well your application closes, I was rather talking about how well it actually runs, be it under XP or 7 or anything else. The leakage won't disapper unless you fix your code in conformity with the Windows SDK specs.

OK if you want me to, I can shoot a short movie under 7 to demonstrate what unfixed DeleteObject() does to system resources.

And no, I do not panic, ever. My signature on the FBSL forum reads literally as follows:

Quote
Mike
"Я старый солдат, мадам, и не знаю слов любви."
"I am an old soldier, ma'am, and I don't know the words of love."
"Je suis un vieux soldat, madame, et je ne connais pas les mots d'amour."
"Ich bin ein alter Soldat, gnädige Frau, und ich weiß nicht die Worte der Liebe."
____________________________________________________________________________________________
(2.2GHz Core2 Duo, 4GB RAM / 2 x GeForce 8600 GTS SLI-bridged, 1GB VRAM)
(x86 Win XP Pro Russian Sp3/x86 Win Vista Ultimate SP1/x64 Win 7 Ultimate Sp1/x64 Win 8 Consumer Preview)


Now please relax yourself and don't you panic either - I'm joking too. In fact, I'm an extremely easy guy to get along with. But when I must, I don't bite, I just gnaw throats without prior notice.

Mike Lobanovsky

  • Guest
Re: Whipping Top
« Reply #4 on: January 15, 2014, 01:51:13 PM »
Absolutely, Peter!

And thank you too, I'm very happy you fixed it. I was in fact looking through your original code again when you posted this message. And OMG, I saw there were no hwnds there any more! You really made my day!

Unfortunately it's already late here so I must go now.

Have a nice night!