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.

Similar Messages

  • 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.

  • 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/

  • 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.

  • Soft/Weak References: rule of thumbs?

    After reading <a target="extern" href="http://java.sun.com/developer/technicalArticles/ALT/RefObj/index.html">Reference Objects and Garbage Collection</a> i browsed my code and replaced my listener containers with versions that store WeakReference objects. The main idea is to avoid memory leaks by storing references to objects that are not needed anymore (the listener container is the only strong reference left).
    Another rule is to use SoftReferences for caches. But I haven't figured out a good way of implementing it (for caches that fill itself with one single SQL statement).
    Are there any other examples where it's good advice to use Soft/Weak References?

    For listeners, you have to make sure that the listener object is hard referenced - which is usually the case. After you release the listener object from the main application/object/thread, because it's finished or you don't need it anymore, the listener holder should not hold on to such references to avoid OutOfMemoryExceptions. Of course, the best way is always to unregister a listener, but unfortunately, we're not living in a perfect world. No listener is forced to unregister, they can simple forget to unregister. For this reason, it's better to tell the listener: if you register yourself, you should know that you are just referenced via WeakReferences. If the listener suddenly doesn't get listener events, this is a coding error which can be traced and fixed. But if a listener forgets to unregister itself, the resulting memory bloat is much harder to trace.
    SQL table caches are difficult. On one hand you want to cache the data, on the other, you want to free this cache memory (temporarily) for more important memory usage. It's always a trade off between 2 advantages. If performance is not the big issue, but you get OutOfMemoryExceptions, then this is critical for the application to continue working. Better a little slower than not at all ... ;-)

  • Please explain soft/weak references to me!

    What I would like to do is have following class:
    abstract class ImageContainer
      private Image img;
      public Image getImage()
        if (img==null)
          renderImage();
        return img;   
      public void lowMemory()
         img=null;
         System.gc();
      abstract protected void renderImage();
    }I think that you get my point, but this doesn't really work, since there's noplace where from call lowMemory() (and I mean low RAM memory, not low swapping memory, since this is to remove swapping during gameplay). I need somehow to use soft references or something like that so I was wondering if you could point me to right direction... I was unable to understand completily the API for package java.lang.ref

    abstract class ImageContainer
    private SoftReference imgRef = new SoftReference();
    public Image getImage()
       Image img = (Image)imgRef.get();
       if (img==null)
          img = renderImage();
          imgRef = new SoftReference(img);
       return img;
    abstract protected Image renderImage();
    }Reference objects "wrap" a regular hard reference, passed into the constructor. The "get" method returns that reference, or null if the object has been collected. (After a GC cycle for WeakReference, after a low-memory condition for SoftReference.) Therefore, upon fetch, call "get" on the reference class and check for null. If null, recreate and create a new reference class instance. Return the object either re-fetched or just created.

  • HT4623 Hi, Im using an iPhone 4 8gb and recently updated my software using my computer to iOS 6.1.3 and some of the tabs are now grayed out and cant function (specific reference to "Show My Caller ID - On/Off tab").  is there a way to fix this or can i do

    Hi, Im using an iPhone 4 8gb and recently updated my software using my computer to iOS 6.1.3 and some of the tabs are now grayed out and cant function (specific reference to "Show My Caller ID - On/Off tab").  is there a way to fix this or can i downgrade back to my default software?

    Hi imobl,
    Thanks for your response, I forgot to add that the five 3uk sims we have in use, I have tried all of them none of them are recongnised non of them have pin codes, I even purchased four more sims Tmobile (original carrier) Vodaphone, 3 and giffgaff.

  • PS CS6 on the mac pro: the bruch in hard and soft is the circle of the bruch bigger than then the effect. How can i bring it to normale?       /Users/jorisneyt/Desktop/Schermafbeelding 2014-11-07 om 10.04.59.png

    PS CS6 on the mac pro: the bruch in hard and soft is the circle of the bruch bigger than then the effect. How can i bring it to normale?

    Go to System Preferences>Accessibility>Display and the set the Cursor Size to Normal

  • How can I record an Audio Instrument (saxophone) and listen to a reference track at the same time?

    How can I record an Audio Instrument, and listen to a reference track at the same time?

    Are you using an external audio controller or the line-in and headphone jacks on the side of your computer? You shouldn't have an issue using headphones when you're recording through the line-in but you may want to make sure you have monitoring on and it's going to the right place.
    If you're using an external audio controller, try making an aggregate device combining the controller and the "built-in output" into the same device. Go to Applications/Utilities/Audio MIDI Setup, click the "+" sign at the bottom left to make a new device and check the "use" boxes to the left of the physical devices you want to use as part of that aggregate device. That is how I use the computer's speakers or headphones to monitor my input as opposed to only being able to use the output on my audio controller.
    Now that I see some of the questions on the side of this page I realize that the 13" MBPs seem to have only one combined input/output jack... That is an incredibly stupid feature. What on Earth could possibly justify that design decision? I suppose if that's the problem you're having you'll have to buy some sort of splitter (if they even make them) or get an external audio controller like an Apogee Duet or something along those lines. I would be furious if they combined those two jacks on all of the MBPs.

  • How to update Tr code FB02   and update the field reference key1 (bseg-xref

    Can any body
    help me how to update   Tr code   fb02
    and  update the field  reference  key1 (bseg-xref1)  with the interest amount
    calculated.
    Below i have  written My  program  flow logic
    The program should read the open items i.e debit items in the customer account,
    Based on the  invoice date and customer payment terms  calculate the due date and then the  interest should be  calculated on that item based on the due date.
    Use the  transaction  fb02  and update the field  reference  key 1 (BSEG-xref1)
    with the interest amount calculated
    Only  consider  customers whose  interest indicator  knb1-vzskz = 'vk'.
    Interest is to be  calculated for every  30  days
    at the rate of  1% .please see example below.
    Document date is 01.01.2007
    for amount  1000SGD   payment  term  7  days
    It becomes  due  on  08.01.2007
    until  06.02.2007 you should not  consider  for calculation of interest
    SGD  on   7.02.2007 run you can consider this  item for interest calculation

    Hi Robert,
    Thanks for answering.
    I am looking at Ref 2 should flow automatically to clearing document from the accounitng document for billing.
    Ex: Billing document is created and accounted. Ref 2 is AB
    Now when receipt is accounted for this biling document this AB should flow automatically to Ref 2 field.
    Thanks
    NNS.

  • When I click it makes the sound twice and is weak

    Whenever I click essentially it sounds ike one hard click and one weak click, my trackpad when i tap makes a click sound also, when usually it doesnt make a sound.

    It will make it easier to help you w/ your problem to know the exact model, size, year built, RAM installed.
    If it's an older machine the track pad might be misadjusted. There is an adjustment screw.

  • High level contract and orders created with reference

    Dear All,
    The client is an integrated flat steel manufacturer. They have entered into quantity contract with high level products like for example Hot rolled coils + Cold rolled coils + Heat Treated plates 5000 T per month. There is no clear cut quantity breakup of each product. On monthly basis customer releases purchase orders with exact grade and dimensions. The requirement is to capture contact for 5000T and create orders with reference to the contract with necessary completion rule. Since exact break up of the high level products is not known controlling of order quantity to 5000T will involve lot of manual intervention. I was thinking in the contract we have high level material "X with 5000T and orders created with reference with actual materials like Hot rolled coils, Cold rolled coils and exact dimension/grade mentioned. Is this possible to have different materials in contract and order with enhancement?
    Any other idea of fulfilling the requirements is welcome.
    Thanks,

    Hi Ramesh,
    Go through  EKPO there is a Table BANFN it will update when you create a PO with reference to PR
    Do se11 > Table EKPO> CtrlShiftF10 > Assign any of PO no. in the EBELN > Execute > you will find BANFN table
    it indicates Purchase Requisition Number. it will update when you create PO with reference to PR.
    Regards,
    Vraj

  • Unable to view Hard and Soft Returns

    I've upgraded to 09 for Keynote and I can no longer see the lighter blue icons indicating hard and soft returns which allow control for my copy flow when animating the text. How do I make these viewable again?

    Try deleting the iCloud account, then sign back in.

  • Missing smoothcam and soft focus effect

    Hi. I recently archived and reinstalled my operating system (leopard). Now when I try to make a quicktime from my timeline, it says, "unable to load softcam and smoothcam effects." Any idea why smoothcam and soft focus disappeared and anyone know how to put them back in? reinstalling final cut is a bad option -- my FC DVDs are at my parents' house (four hours away). I do have a 'previous systems' backup from the archive and reinstall and time machine back-ups...

    Check the /Library/Application Support/ProApps/Internal Plug-Ins/FxPlug folder ... if you don't see Filters.bundle and SmootCam.fxplug then you need to grab those files from the previous systems backup.
    Gotta say tho', a clean reinstall would be best.

  • My hard wear and soft wear crashed, did a backup on all my files.When I now open them the are all "preview"!!! How do I get my old documents back? it should be pages, and numbers, ight now I can't work with them

    My hard wear and soft wear crashed, did a backup on all my files.
    When I now open them the are all "preview"!!!
    How do I get my old documents back? it should be pages, and numbers, right now I can't work with them

    Reinstall OS X

Maybe you are looking for