Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-29-2007, 03:48 AM
Senior Member
 
Join Date: Jun 2007
Posts: 111
Eric is on a distinguished road
How to use the garbaje collector
Garbage collections will be handled by Java Virtual Machine itself means ,how does it know that the object is no longer needed by the program.
Memory recycling, if i use system.gc whether it's a worst programming style or optimized one.
Thanks.

Eric
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-29-2007, 03:53 AM
Member
 
Join Date: Jun 2007
Posts: 95
Felissa is on a distinguished road
As a general statement you don't care if an object is no longer needed. But this means that you need to be careful. Unlike C++ you don't have an explicit destructor. Therefore you need to make sure you clean up after anything like database connections before the object goes out of scope.

I guess I'm not a fan of System.gc() - before the Java Virtual Machine throws an OutOfMemoryException it will do everything it can to clean up memory. If you're calling System.gc() it may help a little bit but I guess I question that it is going to do much for you. A decent Java program doesn't need to do it - know where memory is allocated and make sure you don't have references to it when youd don't want them.
greetings,

Felissa
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 06-29-2007, 03:56 AM
Member
 
Join Date: Jun 2007
Posts: 92
Daniel is on a distinguished road
Overly simple explanation: the Java Virtual Machine will know to collect an object when it is no longer accessible by the code.

Example:
Code:
Object o = new Object(); o = null; // the previously-created object is now unreachable // and is eligible for GC
Greetings.

Daniel
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Interacting with the Java Garbage Collector Java Tip Java Tips 0 03-28-2008 10:04 PM


All times are GMT +3. The time now is 04:14 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org