Release 10.1A: OpenEdge Getting Started:
Object-oriented Programming

> ## Using widget pools

> User-defined classes instantiated using the `NEW` statement, cannot be created in a widget pool. You must assign each instantiated class-based object to an object reference and explicitly delete that object when it is no longer needed.

> Within a procedure file, many dynamic objects can be created using one of three memory allocation strategies. A dynamic object can be created in an unnamed widget pool, a named widget pool, or the system's unnamed widget pool. The `IN` `WIDGET-POOL` phrase of the `CREATE` statement controls which of these three memory pools the resources for the dynamic object go into.

> Within a class file, the existing rules continue to apply for how widget pools behave and from which widget pool memory is allocated for dynamic objects. Thus, you can create zero or more of the following types of widget pools:

> - Named widget pools within the methods of a class.

> - Unnamed widget pools within the methods of a class.

> - A single unnamed widget pool scoped to the entire class.

> If you create a named widget pool in a method, dynamic objects will only be created in the pool if they explicitly reference that widget pool by name.

> If you create unnamed widget pools within a class, the existing rules for how dynamic objects get created in an unnamed widget pool apply. These rules state that a dynamic object is created in the most locally scoped unnamed widget pool, if one has been created, and in the system unnamed widget pool, if no unnamed widget pool has been created. Unnamed widget pools created in a method are scoped to the execution lifetime of that method. Thus, unnamed widget pools created within a method can be explicitly deleted within the method using the `DELETE` `WIDGET-POOL` statement, or they are implicitly deleted by the Progress session when method execution ends.

> In addition, you can create a single unnamed widget pool scoped to the entire class by specifying the `USE-WIDGET-POOL` option on the `CLASS` statement. For more information, see the "Using the CLASS construct" section. The unnamed widget pool created using the `USE-WIDGET-POOL` option is scoped to the entire class and is implicitly deleted by the Progress session when the class-based object is deleted.

> If a class that does not specify the `USE-WIDGET-POOL` option inherits (either directly or indirectly) from a class that does specify the option, the subclass inherits the `USE-WIDGET-POOL` option, also. Furthermore, if a class does specify the `USE-WIDGET-POOL` option, the option applies to any classes that it is derived from when they are running as part of an instance of the class. In other words, at run time, an object has an unnamed widget pool scoped to it if any class in its hierarchy is defined with the `USE-WIDGET-POOL` option. As already noted, an unnamed widget pool created in one of an object’s methods takes precedence over an object's unnamed widget pool during the lifetime of the method's widget pool.

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095