wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "null" Watch "null" New topic
Author

null

W Martin
Greenhorn

Joined: Nov 12, 2003
Posts: 6
i'm just wondering....you know when you're 'finished' with an object you can set it to null to offer it up for garbage collection or whatever...is there any such action that can be performed on primitive data types? i guess they don't take up too many resources in any case but just wondering all the same.
Thanks
Will
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

primitive types are allocated on stack.. they die when the method returns.


Groovy
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
i'm just wondering....you know when you're 'finished' with an object you can set it to null to offer it up for garbage collection or whatever...
Not exactly. Objects can not be "set to null", but you can change references to objects to refer to null. Then, if no living reference refers to some object (as they've perhaps all been told to refer to null), that object would be available for garbage collection.
is there any such action that can be performed on primitive data types? i guess they don't take up too many resources in any case but just wondering all the same.
A primitive reference cannot be instructed to refer to null, as object references can. If a primitive reference exists, it always takes up the same amount of memory, no matter what value it holds.
primitive types are allocated on stack.. they die when the method returns.
Well, let's not forget about all those instance member variables and all those static member variables. They won't "die" until their associated object instance died, or in the case of static variables, until the class were unloaded from memory, which I believe only happens when the JVM terminates.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
W Martin
Greenhorn

Joined: Nov 12, 2003
Posts: 6
okay, thanks for clearing that up
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: null
 
Similar Threads
How to make an image scroll along with my page
" Interesting " question....
EJBHome
Null Check Difference
Java 1.5 StringBuffer/StringBuilder