Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 04-24-2006, 12:59 AM   #1 (permalink)
 
Newb Techie

Join Date: Apr 2006

Posts: 19

himalya

Default Object-out of scope

I was reading abt the Garbage Collection policy of Java. I read that we dont need to use destructors coz of this policy.
The author wrote that the objects are destroyed when they are no longer needed...but this does not happen when an object goes out of scope.

The Ques...
What is the diff between two cond??
himalya is offline  
Old 04-25-2006, 07:38 PM   #2 (permalink)
 
Super Techie

Join Date: May 2005

Posts: 479

furtivefelon

Default

huh? when the object goes out of scope, it means nothing can asscess it anymore, which means it is useless to remain in the program.. thus is destroyed.. what's the problem?
__________________
lisp hacker
running: FreeBSD 5.4 - still learning
develop with: SBCL + emacs for lisp, Anjuta IDE +gcc for c, SPE for python..
browse with: opera
furtivefelon is offline  
Old 04-26-2006, 01:00 AM   #3 (permalink)
 
Newb Techie

Join Date: Apr 2006

Posts: 19

himalya

Default You are too confused....

Thts what I am trying to tell..Objects are not destroyed when they go out of scope..They are dest when not needed, there i a diff bet two cond.
I want to know abt that!!
himalya is offline  
Old 04-26-2006, 01:19 PM   #4 (permalink)
 
Software Developer

Join Date: Mar 2006

Location: Columbus, OH

Posts: 569

jaeusm is on a distinguished road

Default

Quote:
They are dest when not needed
Correct. Garbage collection is the process of freeing memory when an object is no longer referenced by a program. That's the bottom line. You're making this more difficult than it is.
jaeusm is offline  
Old 04-26-2006, 08:18 PM   #5 (permalink)
 
Ultra Techie

Join Date: Jul 2005

Posts: 530

TheHeadFL

Send a message via AIM to TheHeadFL
Default

Well, if its like .NET, an object is destroyed on a periodic schedule.

Many objects may go out of scope, and they are marked as unused, and a garbage collector will periodically come through and free all the memory.

This keeps down the overhead of garbage collection. For instance if you were making recursive calls, when the recursion unwound, you don't want a garbage collector being called potentionall hundreds or thousands of times in a row to free memory. It can be marked unused and removed later. (When the CPU isn't very busy)
__________________
Desktop machine: 2 x Opteron 246, Asus K8N-DL, 2GB PC3200 ECC Reg., XFX GeForce 6600GT, 74gb WD Raptor, 2 x 19\" LCDs, Windows XP x64
Server machine: Intel P4 3.0GHz 2MB EM64T, ECS i865pe, 1GB PC3200, 36gb WD Raptor, Windows Server 2003
Laptop: Dell Inspiron 9100 (Intel P4 3.2GHz 1MB Prescott, i865pe, 512MB PC3200, Mobility Radeon 9700, DVD+R/DL Burner), Windows XP
Linux: P3 450Mhz, 386MB ram, Slackware 10.1 (Running mySQL/Apache)
TheHeadFL is offline  
 
Closed Thread

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

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