How strong ,soft ,weak ,phantom references are used in garbage collection

Hi
to all here.I have doubt that how garbage collection is deciding to cleaning up heap , and what are the roles of strong , soft , weak and phantom reference in garbage collection, i went throgh sun's java docs but i couldn't get any clear idea about those , please can anyone explain me with nice examples for which i will be really thankful.

See:
http://java.sun.com/developer/technicalArticles/ALT/RefObj/

Similar Messages

  • IterateOverReachableObjects and soft/weak/phantom references

    Hi,
    what are soft/weak/phantom references for the JVM TI call IterateOverReachableObjects? Are those reference-objects
    1. ... "normal" objects having references and beeing traversed by this function
    (OR)
    2. ... interpreted as references with hiding the object nature
    (OR)
    3. ... ignored as they are ignored by the GC?
    Thanks,
    Robert

    The reference_kind with JVMTI_REFERENCE_FIELD, the referrer_tag will be the value of the tagged Reference instance, and the referrer_index will be the index of the "referent" field. It is this field that is treated in a special way by the GC.

  • Soft, weak & phantom reference

    Hi all :)
    A short while ago, I began to study "java.lang.ref" package. It's not so easy to me. Also I've gotten many relative questions & answers from this forum, here is a problem confused me for so long time :( Please help me out, thanks!
    import java.lang.ref.*;
    import java.util.Hashtable;
    public class TestMe {
        private Hashtable ht = new Hashtable();
        private ReferenceQueue rq = new ReferenceQueue();
        public TestMe() { }
        private void clearQueue() {
            SoftReference r;
            while ((r = (SoftReference)rq.poll()) != null) {
                Object obj = r.get();
                if (obj != null) {
                    //* Here is the problem: why this always doesn't work?
                    // using weak or phantom reference is same like soft reference here :(
                    System.out.println("=> " + obj);
                ht.remove(r);
        public void put(Object key, Object obj) {
            clearQueue();
            ht.put(new SoftReference(key, rq), obj);
        public static void main(String[] args) {
            TestMe tm = new TestMe();
            int i=0;
            while(true) {
                tm.put(Integer.toString(i++), new String("wow"));

    The reference object is put into the reference queue after all SoftReferences to the reference object have been cleared. Since you're trying to get the reference pointed to by the SoftReference after it's been queued, it is null.
    If you want to store some information to use after the reference object has been queued, you need to subclass the SoftReference class and store the information in a field.

  • I need to find out how much wifi data my apps are using. I have a very limited amount of wifi data, and I am exceeding my monthly allowance. Apparently, even apps I think are not open are sending/receiving data through the wifi and using up my allowance.

    I need to find out how much wifi data my apps are using. I am on a very limited amount of WiFi data each month, which I am regularly exceeding. I have been told to work out which of my apps is using the data. Also, I think I have closed an app by double clicking the home button, then swiping the app up - is this the way to close it, or will it still be sending/receiving data?

    Go into your Settings : General : and turn off background refresh for your apps.  In Settings : Mail  turn Fetch new data to OFF and Load Remote Images to OFF.  This will mean that Mail will only check for messages when you actually use it, and all your advertising junk mail won't have all the images in it.
    Turn off push notifications every chance you get.
    Make sure you are actually quitting apps:  to quit apps press the Home button twice and you should see a bunch of smaller screen images for every open app.  To quit the app swipe from the screen image (not the icon) upward off the top of the iPad.  You can swipe left and right to see more open apps, but there must be no left-right movement on the screen when you swipe upward to close the app.
    Turn off your internet connection when you do not need it.  The easiest way to do this is to swipe up from the bottom of you screen to get the control centre, and then touch the airplane to turn on airplane mode.  You can repeat this sequence to turn it back on again when you need it.  Most especially turn airplane mode on whenever you are sleeping your iPad for long periods.  This will save battery life too.  OR actually turn your iPad off - which means holding the power key down for several seconds until the red swipe bar appears, and then swipe to turn it off.  If you go this route, note that it will take longer to turn on then it takes to wake from sleep.

  • How to find out which users are using SharePoint Designer to make changes in SharePoint 2010 site?

    Hi there,
    How to find out which users are using SharePoint Designer to make changes in SharePoint 2010 site?
    Thanks.

    You need to enable auditing on SharePoint server and it will let you know, if someone makes any critical changes for the same.
    Please walk through this informative KB to enable auditing on SharePoint :https://support.office.com/en-za/article/Configure-audit-settings-for-a-site-collection-f5a346d0-ee0f-4412-a5e6-d9b5abaa1012
    Here is one more resource :
    https://support.office.com/en-in/article/View-audit-log-reports-4293e8d5-4e7d-4201-b8ac-c8e63a100131
    Moreover, if you wish to audit such critical changes automatically, you may consider on this comprehensive application (http://www.sharepointauditing.com/) that helps to track every changes on SharePoint into
    real time and provides the captured data at granular level.

  • Photoshop CS4- Does anyone know how to tell if two people are using same file?

    Photoshop CS4- Does anyone know how to tell if two people are using same file?

    Hi,
    Thanks for your response. I'm not the solution in the link.
    The problem that I am having at work it that several people in our department want to be able to update a file, but we want to be sure that no one else is currently editing that file. If someone has the file open, it's helpful to know the user's name so we can talk about when the next person can edit the file. This works in Excel files that we use, and I would love to find out how to do it in Photoshop and Illustrator.
    Thanks for the help!

  • How to find that 2 references are pointing to same obejct??

    how to find that 2 references are pointing to same obejct??
    i feel that hashCode and equals will not work as far as i understood from javadoc

    I wnat to know above because i want to check if ps in
    this loop is same object or on each iteration new
    object is created
    for (int i = 0; i < 10 ;i ++)
    PreparedStatement ps = con.prepareStatement(sql);
    ps.setInt(1,i);
    ps.executeUpdate();}
    Here's a better question. Why in the world did you put that statement in the loop in the first place, unless the variable 'sql' is modified within?

  • I have about 5,000 images in a Folder.  How can I determine which images are NOT in a Collection?

    I have about 5,000 images in a Folder.  How can I determine which images are NOT in a Collection?

    Create a smart collection with criteria "collection" and "does not contain"; and also with criterion Folder contains (or folder contains all)
    That works if you are thinking about a specific named collection.
    If you are interested in finding photos that are not in ANY collection, the usual trick is "collection" "does not contain" "a e i o u y"

  • Weak, soft and Phantom references

    I have got some confusions about reference types in java. These are:-
    1. How we create weak and soft references! Are they predefined classes and we extend them, or they are interfaces and we implement them, or they are the concepts we implement by following any particular pattern.
    or the references which are gone out of scope are considered as weak references.
    2. can we change the type of reference dynamically! as JVM does it.
    for eg:-
    While the data objects are actually in use (or they are in scope) they are immune because they are strongly referenced by the display windows, once you move to look at something else (or they go out of scope) they become eligable for removal.
    3. There is one set of problem I am facing, could that be resolved by weak or soft references.
    "I set variables at session level(if they are needed at more than one page."
    "At the last page I remove it from session."
    "If for example there are 4 page sequence, and user quits after three steps, then the garbage variables are left in the session."
    "if I make them as weak reference(or soft reference) then would it be a solution. or will it increase any potential risk of loosing the variables in between the process."
    "or is there any way out for my problem using ref package, or it is used only for special purposes, not for a senario like this."
    "or I am bound to use request level instead of session level, in these type of problems(which I am presently doing to solve this problem, but in this case I have to to set same attribute 3 times.)"
    please comment.
    4. What happens when we create an instance of reference queue.
    -->does it give us a reference to the main queue that is used by garbage collector. when destroying objects out of scope.
    that is garbage collector removes the reference of from the object and makes it point to queue element.
    --> or when object goes out of scope, at that time only the reference is removed from the object and is made to point to queue element.
    --> and when we do obj=null; at that time also obj reference is made to point to queue element.
    please comment. I am confused about how java handles references.
    5. does reference queue takes all the junked references.
    if yes!
    then for eg. we are using a background thread and doing some work when instance of class A is cleared, and doing some other work when instance of class B is cleared up by garbage collector.
    queue.remove will return the junked reference, now how will we be determining which object is junked, instance of class A or class B. As reference of object is junked we can't use instanceOf operator.
    please comment.
    Thanks.

    I find the documentation a bit opaque myself.
    You create, say, a Weak reference by creating an object of class WeakReference, or a subclass of same. The object referenced (the referent) is a separate object which you pass in the WeakReference's constructor.
    As long as the referent exist then calling get on the WeakReference object will return it. Once you call get and put the resulting reference in an object you have a hard reference and you know that the referent won't disappear until you let go of it.
    If the referent has been disposed of then get returns null.
    Sometimes you want to do extra cleaning up when a reference is cleared. Then you need to subclass the Reference class you are using to add indentifying information about the object that just disappeared. Obviously this can't be a reference to the object itself, that would be a "Hard" reference and would prevent the object being cleared.
    You then create a ReferenceQueue, which is an ordinary object you own. The Reference objects have a reference to this queue. What happens is the the GC, when it clears one of these Reference objects, adds the Reference to the queue it references. You run a background thread which takes these cleared references from the queue and, using the extra information you added when you subclassed them, does whatever cleaning up you need to do. A typical example is that you have a Map, with the Reference objects as values. Each reference is extended to store the key, so that the cleanup will remove cleared references from the map.
    No, it's not suitable for session objects, because you can't depend on the object still being arround. You can only rely on session timeout. It's a basic problem with web services that you never really know if the user has gone away and abandoned you.

  • How to know what ActiveX references are still open

    Okay, so I'm about the millionth person to post about this topic, but I feel like I know what I should be doing, but have hit a wall.  I have read through pretty much everything I could find in the forums about references and ActiveX.
    I am communicating with Excel via ActiveX, and everything works seemlessly, until I realized that if the user closes the Excel sheet (via an "exit" button on my FP), the "EXCEL.exe" process is still running.  I've read enough to know that this probably points to a reference that I have not closed.
    Problem is, I have poured over my code, and as far as I can tell, I have closed every reference, in the opposite order it was opened (as I read to do in a post earlier).
    Aside from casting references to int's to see what is still considered "active" (as I mentioned earlier, all the ones I can find are closed, so this doesn't help me), is there a way to determine which ActiveX references are still open?
    Even a way outside of LV?  A Microsoft utility even or ...well anything!  This is very annoying, and I know it should be quick and easy, I just have to know what is remaining open.
    Or, am I missing something else that might be keeping EXCEL.exe running?  (yes, I have an application quit and close the application reference)
    Thanks for any help

    Hi Will,
    As you said it yourself closing the same number of references as you open and using Application Quit should be enough to close down Excel.exe.
    Did you run your code in highlight execution to see how the behavior of your program changes when you hit the "Exit" button on your Front Panel?
    If you can post the minimum amount of code that reproduces the error, I will be more than happy to take a look at it.
    Best regards,
    Message Edited by Kalin T on 12-07-2006 03:11 PM
    Kalin T.
    National Instruments
    Attachments:
    activex_excel.jpg ‏16 KB

  • How can you determine which pages are using a specific symbol?

    I want to find all the pages that are using a specific symbol, but I don't know how.  I can't simply switch symbols because some have specific text & want to switch them with more generic smart buttons.  I'll have to find every instance to update the text.
    thanks!

    me too, my file has 39 pages with many unuse symbols, now I want to delete those unuse.
    I found that after deleteing those unuse in Page 1, actually they are being used in other page,
    I can't find the way to delete them all at one time for all pages.
    and I am using CS3

  • How to identify Which function modules are used in the planning area?

    Hi all,
    there are couple of function module derviation is used to derive the calendar year, month, fiscal period etc.
    But how to identify which function module is used in which planning area?
    I cant find out from the where used list from function modules?
    Thanks
    pooja

    Hi Pooja,
    Go to characteristic relationship tab,click on detail icon on extreme left of the derivation,there you will get the name and the details of function module used for derivation.
    Regards,
    Indu

  • How to identify the SQLs which are using the tables and new columns

    Hi
    I m using oracle 10G Database in windows. Developers have added some columns in some of the database tables and were asking to check whether there is some impact on performance or not. I have not done this performance tuning before. Kindly help me how to proceed further.
    How to obtain the sqls which are touching the tables and the new columns? It would be really great if you can help me with this.
    Thanks

    You can try to use DBA_DEPENDENCIES to get PL/SQL objects using tables: http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_1041.htm#i1576452.
    However if SQL code is not stored in database in a trigger, a procedure, a function, a package or a view, it is impossible to retrieve all SQL code referencing some table from database dictionary: for this you would have to analyze application source code.

  • Mifi 4620L - how do I determine which devices are using my data?

    I Have a couple kids connecting to our Mifi4620 and we keep going over our 20gb data limitation.  How can I find out what devices are using data and when as we. As how much so I can track down my high data usage culprit?

    I have made several comments on another forum about my high data usage.  The forum name is "HIGH DATA USUAGE being used". One thing I have found effective in my trouble shooting is to make sure all devices are off and will not auto connect to the WiFi.
    1. Turn on the WiFi and make a log of everything that you do and with a time.
    2. turn on only one device and do what ever you want to use that device for. (ALL other devices off}
    3. Wait about 5 minutes when finished and then turn the MiFi off.
    4. Wait 5 to 10 minutes before turning the MiFi back on to make sure all data got registered.
    5. Do these steps for each device and keep a log of sites visited and what was done on each device.
    6. Log into your Verizon account and go to data then down nearer the bottom there is a box where you can select a device. Select the router phone number and it will give you a detailed listing of data usage and times.  The time in the listing is the time the session started and will add all data used until the MiFi session is ended.  If nothing is connected it will check about about every 160 minutes ( 2 hrs. 45 minutes) you will see a small data usage.  If something is connected you will see data usage every totaled every 6 hours (approximately). By turning the MiFi off you can stop the 6 hour totaling and only total the session up to that time. Of course you have to wait long enough for their computers to get the total data usage.  At one time I would have to wait 3 to 4 days for some of these to show up but recently it shows up within a couple of hours and has always been updated over night. I have been downloading the detail usage since every morning since August.  I made an excel spread sheet that will total on a daily basis the total data used for a day when I do a copy of my download and paste it into my spreadsheet.
    I hope this helps although you might want to read the other forum,  You are not alone with a problem.  I hope you can solve your problem and if you would not mind posting a reply to me as to what you find if you can solve your problem. I thought my problem was solved but it is back and I have run out of ideas as to what else I can check or change. Today I went to Sprint store and can switch to one of their plans and save $18.00 per month but the problem with that is that the Sprint connection is not quite as good where I live.

  • How to find whether user exits are  used in the query or not??

    Hi ,
    I have to make the list of queris in which user exits are used.
    Please any body help me how to find the queries in which user exits are used.
    Thanks
    Maruthi

    Hi Maruthi,
    Using table RSZGLOBV you can find out the queries that have customer exit variables.
    Set filter VRPROCTP (processing type) = 3 means customer exit.
    and the field COMPID will give you the Query name.
    Best Wishes,
    Mayank

Maybe you are looking for

  • How can I change the initial iCloud account without reinstalling?

    i install mountain lion, and set up the icloud with a new @icloud account, however, I have a @gmail account already and used on my iphone4, I want to share information between these devices, so I log out @icloud and log in with @gmail account, contac

  • Is it possible conversion DataSource to byte[ ] ?

    Hello to all.... I�m a Student, and I can understand JMF, but I have this question. Sorry about my english, but I only need a few things.... 1. is it possible to convert a DataSource to byte[ ] ??, I need the DataSource in bytes. In other words the b

  • Changing the page tab structure in the Dashboard

    Hi, In my project we are integrating the dashboards with the web portal. so we need to have the dashboard page tabs as such in the web portal. Can any one please tell me in which xml file we need to make these changes. Thanks, Kart

  • Objects of application scope and clustering.

              I understand that weblogic 6.1 replicates session data to a secondary server in a           cluster. This replication should include objects declared with <jsp:useBean ...           scope="session"/> as well as objects that are explicitly m

  • Sales docu type ZLCO Vs Billing type ZLR - Error

    Hi Experts, Pls help me in the following scenario : I made one sales order with order type ZLCO.(Order relevant Billing type) maintained in VOV8, when i create billing for this order i am getting the following error  Sales document type ZLCO cannot b