1 Reply Latest reply on Sep 1, 2010 7:47 AM by Leo van den berg

    Lots of component objects are created and destroyed per web hit

    Joshua D Novice

      I have this piece of code in the base class of my components, just to understand the creation, destroy pattern of objects. It just seems to create almost all the components and destroys them every time there is a web page invocation. Not sure how to debug this issue, since I am not sure how certain components are getting initialized. I would like to keep the creation/destroying components to be as minimal as possible.


          @PostConstruct
          public void onCreate(Component self) {
              log.trace("Created " + self.getName() + " with scope = "
                      + self.getScope() + " type = " + self.getType() + " hash = "
                      + this.hashCode());
          }
      
          @PreDestroy
          public void onDestroy() {
              log.trace("Destroyed " + this.getClass().getSimpleName() + " hash = "
                      + this.hashCode());
          }
      





        • 1. Re: Lots of component objects are created and destroyed per web hit
          Leo van den berg Master

          Hi,


          don't worry about the creation of objects unlesss you have - for instance - heavy DB-load actions within the creation process. When a seam-component is referenced somewhere on you page (directly used or not), it creates the component. he only things which slows down that process is the log, under normal circumstances a component is already known to Seam and the creatio is a kind of a super construction action. Try to avoid any code blocks with complex initialization which takes time. Shift that to a start action when you really need the component in your page. (For instance the beginning of a long running conversation)


          Leo