Recent

Author Topic: GDi Objects Increasing using TBCButton ?  (Read 6263 times)

Josh

  • Hero Member
  • *****
  • Posts: 1273
GDi Objects Increasing using TBCButton ?
« on: March 29, 2015, 02:45:34 pm »
Hi
I have LAZ 1.3 fpc 2.71 installed latest BGRABITMAP 8 and BGRAControls 3.5

If I create a new project, and then add top this say 10 TBC buttons.
Using Task Manager to display the GDI  Objects
If I run this application. TaskManager will say something like 50 Objects
If I now hover over a TBC Button, the GDI Objects will increase, but not decrease when moved out of the COntrol.
After moving the mouse over the 10 buttons the GDI Objects will have increased by 20
If I click each button, Objects have increased by 40

And are not released.

Any ideas how to correct this GDI Object  'Leak' ?
« Last Edit: March 29, 2015, 02:52:53 pm by josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: GDi Objects Increasing using TBCButton ?
« Reply #1 on: March 29, 2015, 03:13:00 pm »
Hi
I have LAZ 1.3 fpc 2.71 installed latest BGRABITMAP 8 and BGRAControls 3.5

If I create a new project, and then add top this say 10 TBC buttons.
Using Task Manager to display the GDI  Objects
If I run this application. TaskManager will say something like 50 Objects
If I now hover over a TBC Button, the GDI Objects will increase, but not decrease when moved out of the COntrol.
After moving the mouse over the 10 buttons the GDI Objects will have increased by 20
If I click each button, Objects have increased by 40

And are not released.

Any ideas how to correct this GDI Object  'Leak' ?

Do they keep increasing? Or after once increased they stay at the maximum number reached? to put it differently are you sure is a gdi leak and lazy loading?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Josh

  • Hero Member
  • *****
  • Posts: 1273
Re: GDi Objects Increasing using TBCButton ?
« Reply #2 on: March 29, 2015, 03:25:55 pm »
Hi

I dont think it's a leak per se; hence the 'Leak'?

Other controls may increase when in the control,but when exiting control the extra gdi handles are freed, this does not appear to be the beahviour of tbcbutton.

If you have 'hyperthetically' 2000 tbc buttons in an application, and mouse over each; then you now have 6000 gdi objects, if you were to click these 2000 buttons you then exceed the 10000(default gdi handles) and Application crash.



The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Josh

  • Hero Member
  • *****
  • Posts: 1273
Re: GDi Objects Increasing using TBCButton ?
« Reply #3 on: March 30, 2015, 04:31:38 pm »
Hi
Just curious whether anyone has confirmed this?
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

circular

  • Hero Member
  • *****
  • Posts: 4217
    • Personal webpage
Re: GDi Objects Increasing using TBCButton ?
« Reply #4 on: March 31, 2015, 12:07:38 am »
This may be that the drawing of each button state is kept in memory to avoid redrawing it. If you completely free the TBCButton object, does it release the handles?
Conscience is the debugger of the mind

Josh

  • Hero Member
  • *****
  • Posts: 1273
Re: GDi Objects Increasing using TBCButton ?
« Reply #5 on: March 31, 2015, 09:26:18 am »
Hi Circular,

I have attached a small test application (quick and dirty, no real testing) , that creates 250buttons and removes them, if you launch taskmanager and watch the gdi objects.

1) on launch 22 objects,
2) click to create and now  1030
3) if you move the mouse over all controls now 1278
4) if you click some of the buttons you will see the count go up even further, I have not click them all but it will exceed 1500
5) Now if you click button to delete buttons, you will find that the count will go down to 30-32 Not back to 22

Hopefully you can see the Issue.





The best way to get accurate information on the forum is to post something wrong and wait for corrections.

circular

  • Hero Member
  • *****
  • Posts: 4217
    • Personal webpage
Re: GDi Objects Increasing using TBCButton ?
« Reply #6 on: March 31, 2015, 02:33:28 pm »
I tried your test application. Well there is no leak.

When the app starts, and the library BGRABitmap is not used, 24 handles are used.

Then when the buttons are created, 10 handles are used by the library BGRABitmap, so 34 handles are used.

And for each button 4 handles are used by default, and more if more states are stored in memory.

Maybe what you could do is to query to have a property in BCButtons to free button states that are not in use. For example, the hover image and pressed image could be discarded when the normal image is displayed.

Conscience is the debugger of the mind

Josh

  • Hero Member
  • *****
  • Posts: 1273
Re: GDi Objects Increasing using TBCButton ?
« Reply #7 on: March 31, 2015, 02:53:22 pm »
Hi Circular,

Thanks for your reply.

So I assume then that each button is going to take a minimum of 4 handles, I could modify to remove the handles that are created on the fly.

But having each button use 4 handles, is going to restrict its use in my situation.

So it looks like I will have to find another Button component that does not have this impact on the GDI objects.

Thank you for looking into it for me :).

Do you know of another button component that has normal/hover and clicked properties; that does not have this DGI overhead?
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

circular

  • Hero Member
  • *****
  • Posts: 4217
    • Personal webpage
Re: GDi Objects Increasing using TBCButton ?
« Reply #8 on: April 01, 2015, 03:45:03 pm »
Here I added a property to BCButton to limit its memory usage. You can choose low, medium or high. Low is the slowest. So it also depends what speed you need.
http://forum.lazarus.freepascal.org/index.php/topic,24176.msg173350.html#msg173350
Conscience is the debugger of the mind

Josh

  • Hero Member
  • *****
  • Posts: 1273
Re: GDi Objects Increasing using TBCButton ?
« Reply #9 on: April 01, 2015, 04:40:57 pm »
Hi CIrcular,

It must be me, but when I try to download a snapshot of the SVN bgracontrols-64, when I try to compile the package I am getting

C:\laz_components\bgra-controls-code-64\bgrapascalscript.pas(342,61) Hint: Local variable "Offset" does not seem to be initialized
C:\laz_components\bgra-controls-code-64\bgrapascalscript.pas(371,25) Error: Wrong number of parameters specified for call to "FilterRotate"
bgradefaultbitmap.pas(4203,29) Error: Found declaration: FilterRotate(TPointF;Single):TBGRACustomBitmap;
C:\laz_components\bgra-controls-code-64\bgrapascalscript.pas(410) Fatal: There were 2 errors compiling module, stopping

Hopefully something obvious,

Thanks for your rapid help and assistance.
Josh

Apologies forgot to check, my test machine did not have BGRABITMAP 8 installed, I have rectified this and the installation has completed, now to testing.
Again many thanks

Apologies, forgot to check my test machine did not have bgrabitmap 8, installed. Rectified
« Last Edit: April 01, 2015, 05:23:41 pm by josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Josh

  • Hero Member
  • *****
  • Posts: 1273
Re: GDi Objects Increasing using TBCButton ?
« Reply #10 on: April 01, 2015, 06:00:03 pm »
Hi Circular,

Just testing with the application that was creeping towards 9000 objects, after setting the Button value to Low, my GDI Objects have come down to around 1700, with very little change to performance. Wonderful.

What an amazing addition, AWESOME, BRILLIANT, SUPERB.

Thanks for this addition to a Great Package!

Josh
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

circular

  • Hero Member
  • *****
  • Posts: 4217
    • Personal webpage
Re: GDi Objects Increasing using TBCButton ?
« Reply #11 on: April 01, 2015, 10:22:31 pm »
You're welcome  :)
Conscience is the debugger of the mind

Josh

  • Hero Member
  • *****
  • Posts: 1273
Re: GDi Objects Increasing using TBCButton ?
« Reply #12 on: April 02, 2015, 02:11:18 am »
Hi Circular,

Would it be possible to implement similar MemoryUsage property in other components of the bgracontrols package.
I think the tbclabel uses 2 handles by default, I cannot remember when I was checking what the other components were using.

Such a marvelous addition.

Cheers
Josh.
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: GDi Objects Increasing using TBCButton ?
« Reply #13 on: April 20, 2015, 07:10:48 am »
I don't know if these set was thought in meaning of speed. Just to look awesome... But is slower that using directly the native controls or canvas (at least as far as I tested all things under Windows). Of course the result is in the look.

 

TinyPortal © 2005-2018