When should clear() be used?

Asked

Viewed 43 times

1

I made an application using the standard JSF-JPA archetype for list and edit screens, extending from AbstractListPageBean and AbstractEditPageBean respectively, using the Bookmark pages as reference.

I saw that the "New" and "Delete" button has the actionListener pointing to the method clear(). On the editing screens a AbstractEditPageBean has the same method but is not called.

The clear() should be called always when leaving the screen, to avoid accumulation of objects in memory?

1 answer

0


It’s not exactly to prevent memory buildup, but it also helps. Actually in the New and Delete methods you need to clear the information of a Bean that may be being listed or edited. In the case of "Delete" it is clearer, because the record has been read and when it is deleted the information from it must be cleaned. In the case of the New button, it may be that another record has been read, and to ensure that it has nothing and made the "clean".

  • Thanks Emerson, I get the use. I am having memory problems on a production server with only one application (Jboss AS 7.1 + jsf+jpa Demoiselle 2.4.2 application) and I am investigating the possible causes.

  • 1

    It is important to "profile" the application. Check the JVM and Server settings (run.conf). Some settings make quite a difference. In a large majority of cases, both the servers and the JVM run with the "factory" settings and this is not ideal. There is this blog that brings a good initial vision: http://blog.caelum.com.br/beginning/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.