• 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

null

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
primitive types are allocated on stack.. they die when the method returns.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
W Martin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
okay, thanks for clearing that up
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic