Watch what you put in you scoped varables

Your XPage app may run out of memory if you put js functions/classes or domino objects in scoped variables because these objects is not Serializable. So because you can it is not always ok to do that 😉

  1. >Just to clarify:

    1. JavaScript functions (and other non-serializable objects) may be stored in the request scope. They may also be stored in higher scopes (view, session, application) if the application settings are configured to keep all pages in memory. This option enhances performance but reduces scalability. Because this setting may change after the application is already deployed to respond to unforeseen usage patterns, it is best to avoid storing non-serializable objects in any scope to ensure that the setting may be changed at will without requiring potentially significant code changes to support the new setting value.

    2. Domino objects (that is, anything in the lotus.domino package) may safely be stored in the request scope, but should never be stored in any other scope regardless of serialization settings. This is not strictly because they do not implement Serializable, but because they store a link to a C API object that must be garbage collected to avoid memory leaks. In Java agents, we must do this manually, using the recycle method every Domino object shares. In XPages, Domino does this automatically for us at the end of each request (though it's still a good idea to do this manually when reusing the same variable for many objects, such as when navigating a view). As a result, if a Domino object is stored in the viewScope or higher, it will become toxic at the end of the request in which it was stored, because its C object link will have been automatically recycled at the end of that request.

  2. >Great Tim for the update, this is what we need perhaps a wiki document. That could help all developers out there.

  3. What is missing is a mechanism: please store this in a scope and if it is gone I’m fine if you throw it away. Then functions could be cached there and only occasionally need to be reloaded.

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>