AUTOGCN parameter: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
 
Line 20: Line 20:
(by ''''%(object):GarbageCollect''''), and it may be
(by ''''%(object):GarbageCollect''''), and it may be
time consuming.
time consuming.
The AUTOGCN User parameter lets you invoke garbage collection
The <var>AUTOGCN</var> User parameter lets you invoke garbage collection
automatically during a user session whenever normal post-request cleanup
automatically during a user session whenever normal post-request cleanup
&ldquo;leaves behind&rdquo; a number of objects that meets or exceeds the AUTOGCN value.
&ldquo;leaves behind&rdquo; a number of objects that meets or exceeds the <var>AUTOGCN</var> value.


At the end of a request, normal [[Janus SOAP ULI]] object cleanup discards
At the end of a request, normal [[Janus SOAP ULI]] object cleanup discards
Line 40: Line 40:
Orphans reference each other and may be complex, associated with many resources.
Orphans reference each other and may be complex, associated with many resources.
By invoking garbage collection automatically,
By invoking garbage collection automatically,
the AUTOGCN User parameter lets
the <var>AUTOGCN</var> parameter lets
you keep the number of non-discarded, referenced but unreachable, objects
you keep the number of non-discarded, referenced but unreachable, objects
below a threshold value.
below a threshold value.


If AUTOGCN > 0, garbage collection runs whenever the number of referenced,
If <var>AUTOGCN</var> is greater than 0, garbage collection runs whenever the number of referenced,
non-global, non-session objects created by the current request and
non-global, non-session objects created by the current request and
not discarded after the current request's normal cleanup
not discarded after the current request's normal cleanup
is at least the AUTOGCN threshold number.
is at least the <var>AUTOGCN</var> threshold number.


If AUTOGCN = 0,
If <var>AUTOGCN</var> is 0,
automatic garbage collection is not invoked until user logout.
automatic garbage collection is not invoked until user logout.


If garbage collection runs, whether AUTOGCN-invoked or via
If garbage collection runs, whether <var>AUTOGCN</var>-invoked or via
a GarbageCollect method call, you can be notified with a Sirius message
a GarbageCollect method call, you can be notified with a Sirius message
if you set the [[GCSTATS User parameter]] to one of its non-default values.
if you set the <var>[[GCSTATS parameter|GCSTATS]]</var> User parameter to one of its non-default values.
GCSTATS User parameter produces a message that indicates the number
<var>GCSTATS</var> parameter produces a message that indicates the number
of objects the garbage collection discarded and how long it took to do so.
of objects the garbage collection discarded and how long it took to do so.


Line 62: Line 62:
because the request also creates a global object.
because the request also creates a global object.
The request does not trigger automatic garbage collection, however,
The request does not trigger automatic garbage collection, however,
because the AUTOGCN threshold is 70.
because the <var>AUTOGCN</var> threshold is 70.
<pre>
<p class="code">R GCSTATS X'03'
    R GCSTATS X'03'
R AUTOGCN 70
    R AUTOGCN 70
Begin
    Begin


    class Linked
class Linked
    public
public
      variable next is object Linked
  variable next is object Linked
    end public
end public
    end class
end class


    %cycle is object Linked
%cycle is object Linked
    %gl is object linked global
%gl is object linked global
    %i is float
%i is float


    %gl = new
%gl = new


    for %i from 1 to 50
for %i from 1 to 50
    %cycle = new
%cycle = new
    %cycle:next = %cycle
%cycle:next = %cycle
    end for
end for


    print 'End of request'
print 'End of request'
    End
End
</pre>
</p>


If the request runs a second time, the result is the same as the first time,
If the request runs a second time, the result is the same as the first time,
and now one hundred orphans remain in storage.
and now one hundred orphans remain in storage.
If the request runs a third time but AUTOGCN is set to 30, the 50 orphans
If the request runs a third time but <var>AUTOGCN</var> is set to 30, the 50 orphans
that are newly created and not discarded exceed the AUTOGCN threshold,
that are newly created and not discarded exceed the <var>AUTOGCN</var> threshold,
and automatic collection runs, discarding the orphans from all three requests,
and automatic collection runs, discarding the orphans from all three requests,
but not discarding the global object.
but not discarding the global object.
The third request produces the following result:
The third request produces the following result:
<pre>
<p class="code">End of request
    End of request
&#42;**  MSIR.0995: (implicit) Garbage collection completed in
    ***  MSIR.0995: (implicit) Garbage collection completed in
0ms realtime with 0ms CPU time. Discarded 150/151 objects.
    0ms realtime with 0ms CPU time. Discarded 150/151 objects.
</p>
</pre>
'''Note:'''
'''Note:'''
If the second and third times the request ran it was modified to exclude
If the second and third times the request ran it was modified to exclude
Line 108: Line 106:
is not explicitly discarded.
is not explicitly discarded.


For more information about garbage collection, see the [[Janus SOAP Reference Manual]].
For more information about garbage collection, see the [[Global and session objects#Cleanup by garbage collection|"Cleanup by garbage collection"]].


[[Category:User parameters]]
[[Category:User parameters]]
[[Category:Parameters]]
[[Category:Parameters]]

Revision as of 19:00, 13 March 2012

Summary

Default value
0
Parameter type
User
Where set
User resettable
Related products
Janus SOAP
Introduced
Sirius Mods 7.5

Description

The Janus SOAP ULI performs garbage collection automatically at user logout: that is, at logout it removes user-created objects that were not discarded by the user or by the Janus SOAP ULI during and after each request. This garbage collection process can also be invoked explicitly (by '%(object):GarbageCollect'), and it may be time consuming. The AUTOGCN User parameter lets you invoke garbage collection automatically during a user session whenever normal post-request cleanup “leaves behind” a number of objects that meets or exceeds the AUTOGCN value.

At the end of a request, normal Janus SOAP ULI object cleanup discards all objects — if there are no global or session objects defined in the request. However, if the request created global or session objects, normal cleanup discards only objects that are not global and not session and have no references by other request object variables. Global and session objects and any other objects they reference or that are still referenced by other request object variables are not discarded.

Garbage collection sorts through these non-discarded objects and removes those that are not global or session objects or are not accessible, directly or indirectly, from a global or session object. An orphan cycle is a prime example of such an unreachable object. Orphans reference each other and may be complex, associated with many resources. By invoking garbage collection automatically, the AUTOGCN parameter lets you keep the number of non-discarded, referenced but unreachable, objects below a threshold value.

If AUTOGCN is greater than 0, garbage collection runs whenever the number of referenced, non-global, non-session objects created by the current request and not discarded after the current request's normal cleanup is at least the AUTOGCN threshold number.

If AUTOGCN is 0, automatic garbage collection is not invoked until user logout.

If garbage collection runs, whether AUTOGCN-invoked or via a GarbageCollect method call, you can be notified with a Sirius message if you set the GCSTATS User parameter to one of its non-default values. GCSTATS parameter produces a message that indicates the number of objects the garbage collection discarded and how long it took to do so.

The request in the following example creates 50 self-referential, orphan objects which are not discarded by normal request cleanup because the request also creates a global object. The request does not trigger automatic garbage collection, however, because the AUTOGCN threshold is 70.

R GCSTATS X'03' R AUTOGCN 70 Begin class Linked public variable next is object Linked end public end class %cycle is object Linked %gl is object linked global %i is float %gl = new for %i from 1 to 50 %cycle = new %cycle:next = %cycle end for print 'End of request' End

If the request runs a second time, the result is the same as the first time, and now one hundred orphans remain in storage. If the request runs a third time but AUTOGCN is set to 30, the 50 orphans that are newly created and not discarded exceed the AUTOGCN threshold, and automatic collection runs, discarding the orphans from all three requests, but not discarding the global object. The third request produces the following result:

End of request *** MSIR.0995: (implicit) Garbage collection completed in 0ms realtime with 0ms CPU time. Discarded 150/151 objects.

Note: If the second and third times the request ran it was modified to exclude the creation of the global object, the requests' orphans would still not be discarded, because the presence of the global object in the initial request affects object cleanup for the life of the user thread, as long as the global is not explicitly discarded.

For more information about garbage collection, see the "Cleanup by garbage collection".