The users *might* have gone away...there could be references to the
package on instances running on other threads.  The timing of when the
weak references can be cleared are subject to the dynamics of the
garbage collector.  One factor that might result in it not getting
cleared immediately upon termination is uninit methods on class
instances created from the same package.  It's really just a matter of
timing on when that gets cleared.  So if the package manager still has
an instance in the cache, it gets used.  The cache entry can
potentially get cleared out to prevent a persistent memory leak, but
the weak reference will not get cleared at the exact moment the object
goes out of scope.  It takes at least one GC cycle (potentially more
if uninit methods are involved).

Rick

On Wed, Mar 25, 2009 at 12:57 PM, Mark Miesfeld <miesf...@gmail.com> wrote:
> On Wed, Mar 25, 2009 at 9:33 AM, Rick McGuire <object.r...@gmail.com> wrote:
>
>> Well, in this case, it is actually working as designed.  The use of
>> WeakReferences allows a package file to be kept in the global cache,
>> while at the same time not creating a memory leak.  As long as there
>> are some references to the package around to keep things alive, the
>> weak reference will never get cleared and the package is not garbage
>> collected.  Once all users of the package go away, the weak reference
>> can be cleared and the package memory reclaimed.
>
> Okay.  But, once the RexxStart() terminates, shouldn't all users of
> the package have gone away?
>
> The next time RexxStart() is invoked, the prologue of the package
> should run again, shouldn't it?
>
> return_code = RexxStart(1,              /* one argument */
>                      rxargv,         /* argument array */
>                      programName,    /* Rexx procedure name */
>                      NULL,           /* use disk version */
>                      "CMD",          /* default address name */
>                       RXSUBROUTINE,   /* calling as a subroutine */
>                       NULL,           /* no exits used */
>                       &rc,            /* converted return code */
>                       &retstr);       /* returned result */
>
> /* RexxStart() has terminated here.  Now call RexxStart() a
> secondtime.  All users of the package are gone?  But, the proglogue
> does not execute. */
>
>
> return_code = RexxStart(1,              /* one argument */
>                      rxargv,         /* argument array */
>                      programName,    /* Rexx procedure name */
>                      NULL,           /* use disk version */
>                      "CMD",          /* default address name */
>                       RXSUBROUTINE,   /* calling as a subroutine */
>                       NULL,           /* no exits used */
>                       &rc,            /* converted return code */
>                       &retstr);       /* returned result */
>
> --
> Mark Miesfeld
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Oorexx-devel mailing list
> Oorexx-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/oorexx-devel
>

------------------------------------------------------------------------------
_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to