• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can I invoke Runtime.gc() in an EJB

 
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can I invoke Runtime.gc() in an EJB?

As of my knowledge Runtime.getRuntime().gc() is a Java command and we can add it in EJB and we can compile & deploy successfully. while application server executing the line it will request gc. If suppose gc starts then the EJB objects are destroyed ? or any other effect ?

Application server will clear the objects for us rite ?

Any difference bettween Runtime.getRuntime().gc() and System.gc() ?
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Meet Gaurav wrote:Can I invoke Runtime.gc() in an EJB?


Why do you want to do that?

Meet Gaurav wrote:
Any difference bettween Runtime.getRuntime().gc() and System.gc() ?



Javadocs are the best place for such information
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Meet Gaurav wrote:Can I invoke Runtime.gc() in an EJB?



With EJBs in an application server your focus should be on business logic, not garbage collection. The server will handle garbage collection at the best time for all of the applications running on it. Stop and think about it, application servers are not just multi-threaded, they are multi-application, if you could get the server to do a garbage collection when you want it to then that garbage collection just might be in the middle of a very critical process in another EJB application or even during a critical process in your own application. Focus on business and leave the plumping to the application server.
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ran,

I know that.. But this is just an interview question.


Thanks
Casttro
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic