You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Prajapati Manish Narandas <pr...@sigmainfo.net> on 2008/03/26 14:00:49 UTC

Struts2 Action instances are not getting garbage collected

Hi All,
I am using struts2 with spring object factory.
Here, spring is creating action class objects  with request scope and
injecting service layer dependency and service layer objects are singleton
scope.

here, even i have given request scope it doesnt ensure 100 % garbage
collection of my all action class objects.

Can  anybody tell me a way so i can find all action objects garbage
collected once action class has done
its work.

Thanx in advance.

Regards,
manish

Re: Struts2 Action instances are not getting garbage collected

Posted by Alex Shneyderman <a....@gmail.com>.
>  yeah, for some action classes spring inject singleton scoped service
>  dependecies so that might be reason for those action for not getting garbage
>  collected

This can not be. The only way your action will not be garbage
collected if that action instance is refferenced from a long lived
object; not the other way around. Your actions should/could reference
singletons - nothing's wrong with that.

>  but i have one action class which doesn't have any thing which can prevent
>  that class from
>  being garbage collected.

Nothing, that I can see. How do you know that it is not garbage
collected? Garbage collection is a tricky business. Just because you
do not see action classes being collected does not mean they are not
eligible. It might simply mean that GC does not need to collect them.

Alex.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts2 Action instances are not getting garbage collected

Posted by Prajapati Manish Narandas <pr...@sigmainfo.net>.
Thanx Laurie Harper,
I am using jprofiler to monitor instances.
you are right that it may be possible that my action classes might be
referencing
to any long lived objects and that prevents it from being garbage collected.

yeah, for some action classes spring inject singleton scoped service
dependecies so that might be reason for those action for not getting garbage
collected
but i have one action class which doesn't have any thing which can prevent
that class from
being garbage collected.

its as given below:
*

public* *class* AuctionCentralAction *extends* ActionSupport{

/**

*

*/

*private* *static* *final* *long* *serialVersionUID* = 1L;

*private* String catalogList;

*private* String previousCatalog;

*private* String previousCatalogList;



/**

* This method is called while loading the Auction central page.

* *@return
*

*/

*public* String initialize() {

*this*.catalogList="Auction";

*this*.previousCatalogList = "Auction";

*this*.previousCatalog = "0";

*return* "auctionCentralAction";

}

/**

* This method is for validating the user going prior to the My personal
Account page.

* If user is valid then he will take to My personal Account page otherwise
same page will

* be displayed.

* *@return
*

*/

*public* String viewPersonalAccountInfo()

{

String returnString;

UserContext user = ContextProviderRegistry.*getInstance*
().getContext().getUserContext();

String userRole = user.getUserRole();

*if*(userRole.equalsIgnoreCase("ROLE_USER") == *true*){

returnString = "viewPersonalInfo";

}*else*{

returnString = "auctionCentralAction";

}

*return* returnString;

}

*public* String getCatalogList() {

*return* catalogList;

}

*public* *void* setCatalogList(String catalogList) {

*this*.catalogList = catalogList;

}

*public* String getPreviousCatalog() {

*return* previousCatalog;

}

*public* *void* setPreviousCatalog(String previousCatalog) {

*this*.previousCatalog = previousCatalog;

}

*public* String getPreviousCatalogList() {

*return* previousCatalogList;

}

*public* *void* setPreviousCatalogList(String previousCatalogList) {

*this*.previousCatalogList = previousCatalogList;

}

   }


 In my case ,initialize() method will be executed, can anybody tell me
what's there in
the above class which can prevent this class from being garbage collected.

static data member or what?

thanx in advance,

Manish



On Thu, Mar 27, 2008 at 2:46 AM, Laurie Harper <la...@holoweb.net> wrote:

>  Prajapati Manish Narandas wrote:
> > Hi All,
> > I am using struts2 with spring object factory.
> > Here, spring is creating action class objects  with request scope and
> > injecting service layer dependency and service layer objects are
> singleton
> > scope.
> >
> > here, even i have given request scope it doesnt ensure 100 % garbage
> > collection of my all action class objects.
> >
> > Can  anybody tell me a way so i can find all action objects garbage
> > collected once action class has done
> > its work.
>
>
> What makes you think the action instances are not being garbage
> collected? As long as they are request scoped they will be eligible for
> garbage collection as soon as the request they are associated with has
> completed processing, unless you are keeping a longer-lived reference to
> them somewhere.
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Struts2 Action instances are not getting garbage collected

Posted by Laurie Harper <la...@holoweb.net>.
Prajapati Manish Narandas wrote:
> Hi All,
> I am using struts2 with spring object factory.
> Here, spring is creating action class objects  with request scope and
> injecting service layer dependency and service layer objects are singleton
> scope.
> 
> here, even i have given request scope it doesnt ensure 100 % garbage
> collection of my all action class objects.
> 
> Can  anybody tell me a way so i can find all action objects garbage
> collected once action class has done
> its work.


What makes you think the action instances are not being garbage 
collected? As long as they are request scoped they will be eligible for 
garbage collection as soon as the request they are associated with has 
completed processing, unless you are keeping a longer-lived reference to 
them somewhere.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org