This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage collection

 
sumedha rao
Ranch Hand
Posts: 115
Firefox Browser Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the question?

Also you cannot really force the JVM to do Garbage collection even if you use methods of Runtime class.

Update: or the System.gc()
 
sumedha rao
Ranch Hand
Posts: 115
Firefox Browser Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how many are available for garbage collection??
I think it is 0 to 9999 na???
am i right???
explanation:
# for(int i=0; i<10000; i++ ) {
# GC1 x = new GC1(i);
ie: GC x=new GC(0); //now GC(0) is available for garbage collection
GC x=new GC(1);// now GC(1) is available for garbage coolection
...........
ta rara rara...TILL the last one that is 10000
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would say- All the objects created in the loop are eligible for GC once the loop completes the execution. Because the reference variables go out of scope and there's no valid reference to access these objects.
 
sumedha rao
Ranch Hand
Posts: 115
Firefox Browser Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dats what i said...

thanks for the reply
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sumedha rao wrote:dats what i said...

thanks for the reply


Oh yeah. I was thinking that you told the instance created in the last iteration would not be.
 
sumedha rao
Ranch Hand
Posts: 115
Firefox Browser Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

dats what i said(AFTER EDITING )...

thanks for the reply
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sumedha rao wrote:

dats what i said(AFTER EDITING )...

thanks for the reply


If you have edited the post, after someone read/replied to it- Please let others know what was the change. You can always write a remark at the end- Update/Edit: <What ever update>. That way other members who are reading the posts will not get confused.
 
sumedha rao
Ranch Hand
Posts: 115
Firefox Browser Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm sorry..it will actually be from 0 to 9999,because i<10000 and not i<=10000
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic