Weak References in Listener Lists

I've found a common source of memory leaks is when objects that add themselves to listener lists forget to remove themselves when they are done.
It would be nice to generalize and say that listener lists should contain weak references, but there are probably valid cases where a listener's only valid reference is through the listener list.
It would be nice to extend the listener pattern so that the listener could specify if they should be referenced weakly, for examplemodel.addChangeListener(this, true)where true indicates the reference to the listener should be weak.
In some cases like the Model View Controller pattern, it probably makes sense that whenever a view listens to a model it should be weakly referenced. For example, when you construct a JTable and pass the model as a parameter to the constructor, the JTable should always specify a weak reference when it listens to the model.
I think supporting a feature like this in the listener APIs could help reduce the potential for memory leaks and make code a little more maintainable.

There was another time that I dabbled in this idea.
But it always comes back to objects cleaning up
after themselves. Now if its not your code and you
cant ensure good behavior, then perhaps there is
cause. But I'd keep an assert and report the issue
if I saw it trigger.What would fire the assert? The Listener will never be garbage collected while it is listening to something. I assume that you are talking about when the listener is a Swing Object like a JFrame. I don't really like to use gui components as listeners.
If you have to write a clean up method, it kind of defeats the value of having automatic garbage collection to a degree. I like to be able to let my Objects just fall out of scope or just become unreachable when they are no longer needed without having to actively manage their deallocation.

Similar Messages

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

  • Cannot create weak reference to 'classobj' object

    I am trying to run the python Script in a C# program using Iron Python I am getting this type of Error
    cannot create weak reference to 'classobj' object
    I am using this code for running the python code
    var ironPythonRuntime = Python.CreateRuntime();
    try
    dynamic loadPython = ironPythonRuntime.UseFile("Program.py");
    catch (Exception ex)
    Console.WriteLine(ex.Message);

    Hi Mahesh,
    About IronPython issue, It's third-party product.  Please redirect to IronPython forum.  The link as below.
    https://ironpython.codeplex.com/workitem/list/basic
    After search this error,
    this thread tells me.
    Try to use virtualenv. It is used to separate many instances of python and it's libraries - you can have as many virtual environments as possible: python 2.5 , 2.6 , 2.7, whatever - with any combinations of libraries - so you can have for example five
    python 2.6 instances with different sets of libraries configured.
    By the way, here is also a blog talking about
    Running IronPython Scripts from a C# 4.0 Program
    Now I will move your thread to "off-topic" forum. Thanks for your understanding.
    Best regards,
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Weak reference for MapListeners?

    I create objects which implement MapListener and then I register those objects with a CQC. If at some later time the only reference to that object is from the CQC, I would like that object to be garbage collected and the MapListener obviously unregistered. My understanding is that if I create objects and register them as MapListeners, they'll never be GC'd unless I unregister them. Is that right? For my application I'd like the CQC's reference to my MapListener to be a weak reference. Am I correct about all this? Can anyone suggest a work-around for me?
    Thanks,
    Andrew

    Hi Andrew,
    CQC (or any of the named cache implementations for that matter) isn't designed to treat listeners weakly, so there really is no clean way of doing what you are asking that I know of. The only thing I can think of is to wrap the other references to your listener object to incorporate a finalizer that will then turn around and unregister the "weak" listener, upon finalization.
    For example:
    import com.tangosol.net.NamedCache;
    import com.tangosol.util.MapEvent;
    import com.tangosol.util.MapListener;
    import java.util.Iterator;
    import java.util.HashSet;
    import java.util.Set;
    public class MyListener
            implements MapListener
        * The map listener object to wrap.
        * @param listener  the map listener
        public MyListener(MapListener listener)
            m_listenerInternal = listener;
        * Register this listener with the specified cache.
        * @param cache  the named cache to register this listener with
        public void registerWeakListener(NamedCache cache)
            cache.addMapListener(getListenerInternal());
            m_setCache.add(cache);
        // ----- MapListener interface ----------------------------------------
        * {@inheritDoc}
        public void entryInserted(MapEvent evt)
            getListenerInternal().entryInserted(evt);
        * {@inheritDoc}
        public void entryUpdated(MapEvent evt)
            getListenerInternal().entryUpdated(evt);       
        * {@inheritDoc}
        public void entryDeleted(MapEvent evt)
            getListenerInternal().entryDeleted(evt);
        // ----- internal -----------------------------------------------------
        protected MapListener getListenerInternal()
            return m_listenerInternal;
        private MapListener m_listenerInternal;
        private Object      m_finalizer        = new Object()
            public void finalize()
                MapListener listener = m_listenerInternal;
                for (Iterator iter = m_setCache.iterator(); iter.hasNext(); )
                    ((NamedCache) iter.next()).removeMapListener(listener);
        private Set         m_setCache         = new HashSet();
        }

  • Are weak references cleared with soft ones?

    Suppose a program holds both weak and soft references to an object X. Suppose the virtual machine clears all the soft references at once, making X weakly reachable. Is the virtual machine guaranteed to clear all the weak references next before normal execution resumes?
    I ask because I am setting up an automatic interning system for immutable objects of a certain class that will guarantee that at most one object of a given value is reachable by the rest of the program at one time but will allow objects to be garbage collected if necessary. I need to decide what reference object(s) to keep to each interned object. If I keep only a weak reference, objects will be discarded at the whim of the virtual machine; I would prefer to keep them around longer so they don't have to be recreated so many times. If I keep only a soft reference, I am concerned that another part of the program might keep a weak reference. If the answer to my question above is "no", the soft reference could be cleared and the interning system could create a second object with the same value while the first is still accessible via the weak reference. It seems safest to keep both a soft reference and a weak reference and only recreate the object if the weak reference has been cleared.

    Softs hang around until memory needs dictate theygo.
    In my experience (Apple's 1.4 VM) this appears to be
    as soon as GC is run, making them effectively
    useless. Maybe VMs have improved.Not in my experience (Sun 1.4 VM). Soft references hang around forever. I had to stuff my class with bloat to make the instance larger, then change the VM heap size to get it to start collecting my soft references. Whereas the weak references are dumped ASAP. Inside scoop has it that finalizers will delay object collection a bit so be careful of that.
    Also the only guarantee is that soft is cleared before weak when they refer to the same object. in my experience weak references go quickly. Like at the first GC when they are weak. You can not depend on any timing with respect to when the weak will be cleared. I don't think the spec even guarantees that soft will be enqueued before weak. Im not sure on that point.

  • Eclipselink log levels issue with weak references

    Hi all,
    Is it possible to get null pointer exceptions if the log level in eclipselink is set to FINEST and you are logging a weak reference probably in a IdentityWeakReferenceMap and getting a null pointer exception because the weak ref has been garbage collected ?
    -Prashanth.

    I am getting Nullpointer exception when I set log level to FINER or FINEST in persistence.xml.
    DisRootEntityRef entity which is seen in below log has week reference in erml.
    Here is the exception full trace:
    EL Warning: 2010-05-31 17:06:52.328--UnitOfWork(19025200)--Thread(Thread[)--java.lang.NullPointerException
    at oracle.communications.platform.entity.impl.DisRootEntityRefDAO.getRootEntity(DisRootEntityRefDAO.java:300)
    at oracle.communications.platform.entity.impl.DisRootEntityRefDAO.getToString(DisRootEntityRefDAO.java:591)
    at oracle.communications.platform.entity.impl.DisRootEntityRefDAO.toString(DisRootEntityRefDAO.java:584)
    at java.text.MessageFormat.subformat(MessageFormat.java:1246)
    at java.text.MessageFormat.format(MessageFormat.java:836)
    at java.text.Format.format(Format.java:140)
    at java.text.MessageFormat.format(MessageFormat.java:812)
    at org.eclipse.persistence.internal.localization.EclipseLinkLocalization.buildMessage(EclipseLinkLocalization.java:77)
    at org.eclipse.persistence.internal.localization.TraceLocalization.buildMessage(TraceLocalization.java:30)
    at org.eclipse.persistence.logging.AbstractSessionLog.formatMessage(AbstractSessionLog.java:801)
    at org.eclipse.persistence.platform.server.ServerLog.log(ServerLog.java:71)
    at org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:2571)
    at org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:3664)
    at org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:3636)
    at org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:3612)
    at org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:3534)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.logDebugMessage(UnitOfWorkImpl.java:5397)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerExistingObject(UnitOfWorkImpl.java:3874)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerExistingObject(UnitOfWorkImpl.java:3844)
    at org.eclipse.persistence.queries.ObjectBuildingQuery.registerIndividualResult(ObjectBuildingQuery.java:362)
    at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally(ObjectBuilder.java:588)
    at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:549)
    at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:489)
    at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:441)
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:635)
    at org.eclipse.persistence.queries.ReadAllQuery.registerResultInUnitOfWork(ReadAllQuery.java:838)
    at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:464)
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:997)
    at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:670)
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:958)
    at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:432)
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1021)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2858)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1225)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1207)
    at org.eclipse.persistence.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:85)
    at org.eclipse.persistence.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:75)
    at org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:83)
    at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiateImpl(UnitOfWorkValueHolder.java:161)
    at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:230)
    at org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:83)
    at org.eclipse.persistence.indirection.IndirectList.buildDelegate(IndirectList.java:237)
    at org.eclipse.persistence.indirection.IndirectList.getDelegate(IndirectList.java:397)
    at org.eclipse.persistence.indirection.IndirectList$1.(IndirectList.java:525)
    at org.eclipse.persistence.indirection.IndirectList.listIterator(IndirectList.java:524)
    at org.eclipse.persistence.indirection.IndirectList.iterator(IndirectList.java:488)
    at oracle.communications.platform.persistence.impl.PomsArrayList.iterator(PomsArrayList.java:598)
    at oracle.communications.platform.entity.impl.DisResultGroupDAO.getRootEntities(DisResultGroupDAO.java:765)
    at oracle.communications.integrity.scanCartridges.sdk.RootEntityLoaderImpl.(RootEntityLoaderImpl.java:37)
    at oracle.communications.integrity.scanCartridges.sdk.BaseDiscrepancyDetectionController.init(BaseDiscrepancyDetectionController.java:71)
    at oracle.communications.integrity.scanCartridges.sdk.BaseDiscrepancyDetectionController.invoke(BaseDiscrepancyDetectionController.java:41)
    at oracle.communications.integrity.cartridges.ciscoextensioncartridge.detectionplugins.ciscodiscrepancydetectionsample.CiscoDiscrepancyDetectionSampleMessageDrivenBean.onMessage(CiscoDiscrepancyDetectionSampleMessageDrivenBean.java:109)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy343.onMessage(Unknown Source)
    at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:466)
    at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:371)
    at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:327)
    at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4585)
    at weblogic.jms.client.JMSSession.execute(JMSSession.java:4271)
    at weblogic.jms.client.JMSSession.executeMessage(JMSSession.java:3747)
    at weblogic.jms.client.JMSSession.access$000(JMSSession.java:114)
    at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:5096)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    oracle.communications.integrity.cartridges.ciscoextensioncartridge.detectionplugins.ciscodiscrepancydetectionsample.CiscoDiscrepancyDetectionSampleMessageDrivenBean
    java.lang.NullPointerException
    at oracle.communications.platform.entity.impl.DisRootEntityRefDAO.getRootEntity(DisRootEntityRefDAO.java:300)
    at oracle.communications.platform.entity.impl.DisRootEntityRefDAO.getToString(DisRootEntityRefDAO.java:591)
    at oracle.communications.platform.entity.impl.DisRootEntityRefDAO.toString(DisRootEntityRefDAO.java:584)
    at java.text.MessageFormat.subformat(MessageFormat.java:1246)
    at java.text.MessageFormat.format(MessageFormat.java:836)
    at java.text.Format.format(Format.java:140)
    at java.text.MessageFormat.format(MessageFormat.java:812)
    at org.eclipse.persistence.internal.localization.EclipseLinkLocalization.buildMessage(EclipseLinkLocalization.java:77)
    at org.eclipse.persistence.internal.localization.TraceLocalization.buildMessage(TraceLocalization.java:30)
    at org.eclipse.persistence.logging.AbstractSessionLog.formatMessage(AbstractSessionLog.java:801)
    at org.eclipse.persistence.platform.server.ServerLog.log(ServerLog.java:71)
    at org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:2571)
    at org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:3664)
    at org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:3636)
    at org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:3612)
    at org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:3534)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.logDebugMessage(UnitOfWorkImpl.java:5397)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerExistingObject(UnitOfWorkImpl.java:3874)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerExistingObject(UnitOfWorkImpl.java:3844)
    at org.eclipse.persistence.queries.ObjectBuildingQuery.registerIndividualResult(ObjectBuildingQuery.java:362)
    at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally(ObjectBuilder.java:588)
    at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:549)
    at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:489)
    at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:441)
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:635)
    at org.eclipse.persistence.queries.ReadAllQuery.registerResultInUnitOfWork(ReadAllQuery.java:838)
    at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:464)
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:997)
    at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:670)
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:958)
    at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:432)
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1021)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2858)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1225)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1207)
    at org.eclipse.persistence.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:85)
    at org.eclipse.persistence.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:75)
    at org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:83)
    at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiateImpl(UnitOfWorkValueHolder.java:161)
    at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:230)
    at org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:83)
    at org.eclipse.persistence.indirection.IndirectList.buildDelegate(IndirectList.java:237)
    at org.eclipse.persistence.indirection.IndirectList.getDelegate(IndirectList.java:397)
    at org.eclipse.persistence.indirection.IndirectList$1.(IndirectList.java:525)
    at org.eclipse.persistence.indirection.IndirectList.listIterator(IndirectList.java:524)
    at org.eclipse.persistence.indirection.IndirectList.iterator(IndirectList.java:488)
    at oracle.communications.platform.persistence.impl.PomsArrayList.iterator(PomsArrayList.java:598)
    at oracle.communications.platform.entity.impl.DisResultGroupDAO.getRootEntities(DisResultGroupDAO.java:765)
    at oracle.communications.integrity.scanCartridges.sdk.RootEntityLoaderImpl.(RootEntityLoaderImpl.java:37)
    at oracle.communications.integrity.scanCartridges.sdk.BaseDiscrepancyDetectionController.init(BaseDiscrepancyDetectionController.java:71)
    at oracle.communications.integrity.scanCartridges.sdk.BaseDiscrepancyDetectionController.invoke(BaseDiscrepancyDetectionController.java:41)
    at oracle.communications.integrity.cartridges.ciscoextensioncartridge.detectionplugins.ciscodiscrepancydetectionsample.CiscoDiscrepancyDetectionSampleMessageDrivenBean.onMessage(CiscoDiscrepancyDetectionSampleMessageDrivenBean.java:109)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy343.onMessage(Unknown Source)
    at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:466)
    at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:371)
    at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:327)
    at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4585)
    at weblogic.jms.client.JMSSession.execute(JMSSession.java:4271)
    at weblogic.jms.client.JMSSession.executeMessage(JMSSession.java:3747)
    at weblogic.jms.client.JMSSession.access$000(JMSSession.java:114)
    at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:5096)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

  • JMX and weak references

    Hi,
    We are having a problem where an RMI object is not being garbage collected. A fellow developer has suggested that since the JMX server has a reference to the object it will never be garbage collected. Does anyone know if the JMX server keeps a weak reference to an object or to garbage collect the object you must unload it from the JMX server?

    Hi,
    We are having a problem where an RMI object is not
    ot being garbage collected. A fellow developer has
    suggested that since the JMX server has a reference
    to the object it will never be garbage collected.
    Does anyone know if the JMX server keeps a weak
    reference to an object or to garbage collect the
    object you must unload it from the JMX server?not sure exactly what you are saying; but jmx deals with mbeans only. if your remote object is not an mbean object, it would have nothing to do with jmx. to kill an mbean object, use jms to unload it.

  • Garbage Collection Weak References

    Can someone please explain to me the point of Weak References.
    here is what i understand
    // we have a strong reference object
    String strong = new String("i am a strong reference");
    // we create a weak reference object
    Reference wr = new WeakReference(strong);
    Now what i have understood from my readings is that now when strong dereferences the object that was initially created the garbage collector deallocates the memory for that item.
    but what is the point of a WeakReference?

    This might be useful for you.
    http://java.sun.com/developer/technicalArticles/ALT/RefObj/

  • Reference object structure list iam getting only functional location no

    Dears
    There is one query from our client that in reference object structure list he is getting only functional location no and not functional location description.i asked him to go to menu settings field selection -functional location and from the choose list  ask him to select functional location description .But still he couldn't get the required one. Can any body tell me the reason.

    Hi,
    You can achieve it from OIAJ tcode and set the required setting for your field IFLO-PLTXT.
    Regards,
    Keerthi

  • Weak references for variables

    Hello,
    UseWeakReference exists for addEventListener and for dictionaries. Is there any way to set a variable to be a weak reference? Kind of like WkPtr<> in boost for C++? I'd like to use this for function callbacks, amongst other things. Would hate to have to wrap everything in a dictionary as a hack.
    Thanks!

    Alex,
    Not quite what I was hoping for as an answer, but it's an answer nonetheless.
    Thanks!
    Mark

  • Clearing weak references with inner classes

    I have a class which contains several inner classes. During it's lifetime, this object creates several instances of it's internal objects and uses them only internally.
    I also have a single weak reference that links to my object from anywhere external to the program.
    While profiling, I discovered a memory leak. After examining the core dump under jhat, it appears that the only objects linking to this object are that weak reference from the external program and several intantiated inner classes that reference my object via their implicit this$0 field.
    Is this possible? Does mixing inner classes and weak references stop the garbage collector from reclaiming classes?

    Based on the information you provide, I question your assertion that these inner objects are used only internally. The most obvious explanation is that you're leaking them and something else is holding a hard reference to them.

  • Reference to class List is ambiguous

    Hello,
    I've started to make my first java program in which I use AWT.
    When I compile the file, it gave me this error:
    "reference to List is ambiguous, both class java.awt.List in java.awt and class java.util.List in java.util match"
    So I use some tools from the java library: java.util ( f.e. arrays)
    and I use of course the library: java.awt
    Now when I try to make a list:
    f.e.
    List data = new List(10,false);
    The program doesn't know if I want to use the method List, from AWT or UTIL
    In fact, I want to use this from AWT.
    How can I make that clear.
    Thx

    It will probably work if you add "import java.awt.List;" to your imports. If that doesn't do it, you will need to specify which List when you declare or instantiate it. For example, if you now have
    List list = new List(10,false);
    Then change it to
    java.awt.List list = new java.awt.List(10,false);

  • Open references of other list items from a list item in the same window or tab

    Hi there,
    We have migrated from lotus notes to sharepoint. We have converted the lotus notes forms to sharepoint forms. Basically the list items are pages and there are links of other pages in a page.
    My problem is I want to open the other pages in the same tab or window and not in a separate window.(currently the links open in a separate window which is not the requirement.)
    In terms of sharepoint I would say,
    I have references(links)  to other list items of the list in a single list item. I want to open the other list items in the same window (tab).
    How can we achieve this?? If possible without much codes??
    Please suggest.
    Any help will be highly appreciated.
    Thanks in advance

    See:
    *http://kb.mozillazine.org/browser.link.open_newwindow
    *1: current tab; 2:new window; 3:new tab;
    For links opened via JavaScript you can look at this pref:
    *http://kb.mozillazine.org/browser.link.open_newwindow.restriction
    You can open the <b>about:config</b> page via the location/address bar.
    You can accept the warning and click "I'll be careful" to continue.
    *http://kb.mozillazine.org/about:config

  • Weak references

    Why is it that SoftReference overrides the get() method in the Reference class. I can undertand that phantom references must do this as they always return null from get() but why is it so with soft refs?
    Andrew

    It updates a Timestamp field each time the get method is invoked. The VM may use that field when selecting soft references to be cleared (but it isn't required to do so)

  • Re: array of references to linked lists

    Hi, im having a little problem seeing the wood from the tree...shouldnt be too hard for a fresh pair of eyes...ive been trying for a while now(read ages !!).
    I have an array which will be populated with seperate linked lists (StudentList class) which are populated from a console interface (prompt).
    It seems to work fine, however .. each list entered will overwrite the last by adding itself to it. eg :
    list 1 is added : adam 998 albert 999
    list 2 is added : john 123 jill 666
    lists[0].print() : jill 666 john 123 albert 999 adam 998
    lists[1].print() : jill 666 john 123 albert 999 adam 998
    it should give
    lists[0].print() : jill 666 john 123
    lists[1].print() : albert 999 adam 998
    the code is below,
    cheers for ANY help,
    ta.
    import java.io.*;
    import java.util.*;
    public class StudentId {
         public static void main(java.lang.String[] args) {
              StudentList[] lists = new StudentList[20];
              for (int i = 0; i < lists.length; i++) {
                   lists[i] = new StudentList();
              int n = 0;
              BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
              for(;;) {
                   System.out.print("Please enter a student record list> ");
                   try {
                        //StudentList list = new StudentList();
                        String line = in.readLine();
                        if (line.equals("quit")) {
                             break;
                        StringTokenizer tokenBag = new StringTokenizer (line," ");
                        while (tokenBag.hasMoreTokens()) {
                             try {
                                  String name = tokenBag.nextToken();
                                  String idString = tokenBag.nextToken();
                                  int id = Integer.parseInt(idString);
                                  lists[n].insert(name, id);
                             catch(Exception e) {
                                  System.out.println("Input error : " + e);
                   catch (Exception e) {
                        System.out.println("exception : " + e);
                   n += 1;
              for (int i=0; i<n; i++) {
                   System.out.println("element " + i);
                   lists.print();

    other class (Int node class is standard node class altered
    public class StudentList {
         private static IntNode head;
         private static int count;
         public StudentList() {
              head = null;
              count = 0;
         public boolean isEmpty() {
              if (count == 0) return true;
              else return false;
         public int size(){
              return count;
        public IntNode getHead() {
              return head;
         public void printHead() {
              System.out.println(head.getName() + " " + head.getId());
         public IntNode getTail() {
              IntNode cursor;
              for (cursor = head; cursor != null; cursor = cursor.getLink()) {
              return cursor;
         public void insert(String name, int id){
              head = new IntNode(name, id ,head);
              count++;
         public IntNode searchFor(String name) {
              IntNode cursor;
              cursor = head.listSearch(head, name);
              return cursor;
         public IntNode searchFor(int id) {
              IntNode cursor;
              cursor = head.listSearch(head, id);
              return cursor;
         public void print() {
              IntNode cursor = head;
              for (int i=0; i<count; i++) {
                   System.out.println(cursor.getName()+" "+cursor.getId());
                   cursor = cursor.getLink();
         public void insertListBefore(IntNode match, StudentList list) {
              IntNode preCursor = head.getPrevious(head, match);
              IntNode cursor;
              cursor = this.searchFor(match.getName());
              preCursor.setLink(list.getHead());
              list.getTail().setLink(cursor);
    }

Maybe you are looking for

  • IPod no longer plays my purchase music???

    Hi everyone, I've recently moved my music collection to a different computer and everything seems fine except purchased songs etc won't play on my iPod. They transfer over fine but when it goes to play anything purchased it skips to the next track. I

  • "BLACK" screen after update to 10.5.8

    I did the update this afternoon and had a similar issue. Immediately after the reboot from installing the update, the computer came up with a a bunch of operating system information with the last statement saying: "Panic: rebooting....". The screen t

  • Downloading for hours is something wrong with the Imac?

    Download of Mountain Lion is not progressing more than 3 hours according the status bar.

  • Ld problems

    /usr/bin/ld: cannot find -lHStransformers-0.2.2.0-ghc6.12.3 collect2: ld returned 1 exit status     Aborting... error: Build failed [root@vps-626-1 snap]# updatedb [root@vps-626-1 snap]# locate HStran /root/.cabal/lib/transformers-0.2.2.0/ghc-6.12.3/

  • Rejection for return delivery - Confirmation

    Hi all, While i'm doing "return delivery" system should ask 'Rejection for return delivery'( like poor quality etc..) but, without this indicator i can confirm the return delivery. How to make this field as a mandatory ( rejection for return del) Ret