jsf 2 - JSF - List of objects in a Managed Bean and memory management question -
i creating first jsf application. question going simplify try , make question clear possible.
the application creating simple contact storing application allow create new contact, store information such addresses, phone numbers, work, , upload files associated contact.
when application loads user displayed list of contacts have been created. can click on contact's image open contact , view of information stored on them. question comes in.
all of information stored in contactmanager.java managed bean. of data on contact displayed in datatables. there address datatable, phone datatable, uploads datatable. each datatable view resides within appropriate tab. using primefaces create tabs. when contact opened system has load maybe 10 lists of data dropwdown lists used select values. populate these datatables in tabs.
@managedbean @viewscoped public class contactmanager implements serializable { private contact contactinfo; private list<phone> phones; private list<addresses> addresses; private list<company> jobs; private list<files> uploads; //dropdown select lists private list<country> countrylist; private list<state> statelist; //getters , setters everyting ..... (i not going type out there) @postconstruct public void opencontact() { try { this.countrylist = mydao.getcountrylist(); this.statelist = mydao.getstatelist(); this.addresses = mydao.getaddresses(contactinfo.contactid); this.phones = mydao.getphones(contactinfo.contactid); this.jobs = mydao.getjobs(contactinfo.contactid); this.uploads = mydao.getuploads(contactinfo.contactid); } } }
so when user opens contact of contact information loaded memory can displayed in view.
this example small actual amount of lists , data storing simplification sake wondering memory management.
my system going used number of users , loading of information worries me. when memory allocated of cleared? responsible clearing it?
if have 10 users , viewing contacts have big tables lot of data fear going bring standstill.
currently runs fine on system know of these tables , lists kept in memory until either user clicks , opens new contact or closes application.
any insight on if right way of doing things or how handle large information great.
i using jsf 2.0 / primefaces 2.2rc2-snapshot
if tables big, need lot of memory on server side, or without jsf.
do not use rich faces tables; use ui:repeat , write custom paging it.
primefaces tables better h:datatable or rich:datatable.
jsf 2.0 uses 50% less memory each user.
also, use @requestscoped beans , viewscoped; not use sessionscoped beans.
you can remove sessions beans session faces context.
context = facescontext.getcurrentinstance(); externalcontext = context.getexternalcontext(); externalcontext.getsessionmap().remove("usercontext"); externalcontext.getsessionmap().remove("sessioncontroller");
etc.
also, if have id store in page , think can not use requestscoped beans, mistake integrate application tomahawk myfaces, , use t:savestate value="#{bean.categoryid}"/>
it store id or objects, list maps, in current page scope.
Comments
Post a Comment