Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Delphi
  4. Performance of visual components

Performance of visual components

Scheduled Pinned Locked Moved Delphi
performancequestiondiscussion
4 Posts 3 Posters 13 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Corinna John
    wrote on last edited by
    #1

    Hello, when I place a TQuery component, on a form, it consumes memory until the application quits. When I create/free the TQuery everytime I actually need it, the construction/destruction consumes time. What do you think is better for the application's performance? Do you keep the visual component in memory all the time, or do you prefer to create objects on demand?

    This statement is false.

    B N 2 Replies Last reply
    0
    • C Corinna John

      Hello, when I place a TQuery component, on a form, it consumes memory until the application quits. When I create/free the TQuery everytime I actually need it, the construction/destruction consumes time. What do you think is better for the application's performance? Do you keep the visual component in memory all the time, or do you prefer to create objects on demand?

      This statement is false.

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      Hi, By default it should works properly and without consuming much memory, I use Delphi too but I never had that problem. Check if somewhere else is problem and if you figure out then notify me,ok? Regards.


      I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

      C 1 Reply Last reply
      0
      • B Blue_Boy

        Hi, By default it should works properly and without consuming much memory, I use Delphi too but I never had that problem. Check if somewhere else is problem and if you figure out then notify me,ok? Regards.


        I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

        C Offline
        C Offline
        Corinna John
        wrote on last edited by
        #3

        Blue_Boy wrote:

        if somewhere else is problem

        There is no problem at all. I only asked what people think about memory usage and performance. I made a test with - a DataModule with a TQuery and - a simple class that creates the TQuery on the fly both containing the same method. Strangley, the method ran a few milliseconds faster in the class without visual components. The DataModule with visual components worked a few milliseconds slower, though (in theory) the components involved should have been the same. That means, the way you create instances - by drag&drop or create/free - actually does matter.

        This statement is false.

        1 Reply Last reply
        0
        • C Corinna John

          Hello, when I place a TQuery component, on a form, it consumes memory until the application quits. When I create/free the TQuery everytime I actually need it, the construction/destruction consumes time. What do you think is better for the application's performance? Do you keep the visual component in memory all the time, or do you prefer to create objects on demand?

          This statement is false.

          N Offline
          N Offline
          nortee
          wrote on last edited by
          #4

          Hi Corina,

          Corinna John wrote:

          when I place a TQuery component, on a form, it consumes memory until the application quits.

          The amount of memory that your query will consume is directly related to the amount of data which you are retrieving from the database, and as such cannot be helped. What you could do is look at how many fields are being returned and reducing that amount to only those fields that you need.

          Corinna John wrote:

          When I create/free the TQuery everytime I actually need it, the construction/destruction consumes time.

          I've found that creating/destroying the components dynamically isn't time consuming. What will take time is establishing the connection to the database and the subsequent retrieval of the data from the query. Since I hardly every use data-aware controls, most of the time I dynamically load the data to the screen(s) by creating a data controller which will provide the functionality for retrieving/updating the data from the database. Ideally this controller will have some database connection object within it, and a query/command object to query the database with. These data objects should be created and destroyed in the controller's constructor/destructor respectively. Then, by using events, you can perform some kind of action on the resulting query which you executed. So a controller would look something like this (I see you are using the TQuery component, and although I am using ADO, the theory is still basically the same):

          unit uDataController;

          interface

          uses
          ADODB;

          type
          // my uber-super user defined event :P
          TOnRetrieveData = procedure (ASender : TObject; AResultData : TADOQuery) of object;

          TDataController = class(object)
          private
          FOnRetrieveData : TOnRetrieveData;
          FDBConnection : TADOConnection;
          FADOCommand : TADOCommand;

          procedure InitialiseDBStuff;
          

          public
          constructor Create(AOnRetrieveDataEvent : TOnRetrieveData);
          procedure ExecuteSQL(const ASQLString : string);
          end;

          implementation

          constructor TDataController.Create(AOnRetrieveDataEvent : TOnRetrieveData);
          begin
          inherited Create;

          InitialiseDBStuff;

          // Assign the event...
          FOnRetrieveData := AOnRetrieveDataEvent;

          end;

          procedure TDataController.InitialiseDBStuff;
          begin
          // Initialise the connection and command components
          FDBConnection := TADOConnection.Create(nil);
          FADOCommand := TADOCommand

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups