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 04-12-2008, 06:32 AM
Member
 
Join Date: Apr 2008
Posts: 5
SaYuNaRa is on a distinguished road
what happen if an object set to null
if i set an object to null, is it make an object to an empty object?
and the memory use by that object is remove or not?

example ?
ImageIcon icon = new ImageIcon(file) //example use 8 byte
Image img = icon.getImage(); //example use 8 byte

if i set to null:

icon = null; // is the memory use by icon remove or not
img = null; // is the memory use by img remove or not

is that memory use by icon and img remove or not? if not remove how to remove the icon and img memory becouse i want use the same object to set another refrence.

I do that becouse it make my app out of memory
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-12-2008, 09:00 PM
Chris.Brown.SPE's Avatar
Member
 
Join Date: Apr 2008
Location: State College, PA
Posts: 50
Chris.Brown.SPE is on a distinguished road
Send a message via AIM to Chris.Brown.SPE
If you use the System.gc() after you set the object to null it should free up the memory. It may need to be called multiple times to make sure all unused memory is freed up. Check out the following website for more information.

[JavaSpecialists 029] - Determining Memory Usage in Java
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-14-2008, 06:37 AM
Member
 
Join Date: Apr 2008
Posts: 5
SaYuNaRa is on a distinguished road
thx for your help..
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-17-2008, 05:50 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 527
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
I wonder why you like to set it to null? What are you planning for?

regards,
sukatoa
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-17-2008, 06:09 AM
Member
 
Join Date: Apr 2008
Posts: 5
SaYuNaRa is on a distinguished road
i want set to null, becouse i want use the same object to refer to other. like img object:

this i want:
ico = new ImageIcon("c:/image/pic1.pmg")
img = ico.getimage();


this i refre to other:
ico = null;
img = null;
so i can set new refer
ico = new ImageIcon("c:/image/pic2.pmg")
img = ico.getimage();

if i not set it to null before i use its again my app will out of memory. this right or not?
i do what Chris.Brown said, and it work, my app not of memory.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 04-17-2008, 06:15 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,376
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
What you mean out of memory. What happened if you not set to null, before use again?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
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
Img.getWidth(null); gives -1 why? willemjav New To Java 0 02-15-2008 04:06 PM
What is NULL bugger New To Java 1 01-09-2008 06:55 PM
Creating object of Type Object class venkatv New To Java 3 07-17-2007 05:33 PM
Operator < cannot be applied to java.lang.Object, Object Albert Advanced Java 1 07-13-2007 05:19 PM
To happen of ActionErrors to ActionMessage Eric New To Java 1 07-05-2007 09:09 PM


All times are GMT +3. The time now is 03:49 PM.


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