Spring beans are singleton by default and so will never be garbage collected
while your app is running, nor will any object referenced by them. Singleton
scope is good unless you have a reason for something else. I'm using all
singleton objects. If you're having memory problems, look at your code for
places where you're improperly retaining object references.
On Fri, Jan 14, 2011 at 6:09 PM, chauzer <chauzer_at_gmail.com> wrote:
>
> I have jersey running w/ spring, and an embedded jetty server (the config
> of
> the server is in the spring application context XML). I noticed that my
> objects that i create, just a simple javabean, thats created in my resource
> class never gets garbage collected when i profile my app w/ JProfiler. Any
> ideas what could be causing this?
>
> My jersey resource is instantiated by Spring w/ the default type, which i
> think is Singleton. I read that most people use "request" scope for their
> resources? Woudl it be possible to use singleton still or is that what
> keeps
> the reference to all these objects not being GCed?
>
> The reason i dont have it as request scope is that I receive an error when
> trying to use request scope. I think its related to how I start up the
> jetty
> server w/ a spring XML and it loads the jersey spring servlet that i had to
> make my own version which sets the application context of my apps spring
> XML
> inside into that spring servlet so they use the same app context.
>
> Any suggestions?
>
> Thanks
> --
> View this message in context:
> http://jersey.576304.n2.nabble.com/objects-are-not-getting-garbage-collected-still-referenced-by-the-resource-tp5923768p5923768.html
> Sent from the Jersey mailing list archive at Nabble.com.
>