Power to Build

Home » Misc » Sybase EAServer: Taking Control -Object Pooling

Sybase EAServer: Taking Control -Object Pooling

Memory/Object Pooling
Memory allocation is an expensive task in any system. Whether it’s a C program doing malloc or a Java program creating objects on the fly, the system has to constantly go to memory handler and request for more memory. Releasing used memory was also a problem, it took resources, and not releasing properly caused memory leaks. Java came up with Garbage collection (gc), but even this uses a lot of resources, if not setup properly.In a heavily used system like ours, this means the system will be spending considerable amount of time in object creation and destruction (this will be done by Garbage collection). To alleviate this problem, some type of pooling (or caching) method is often used. Simply put, this is where memory released is held in a pool and reused when the next person asks for it. This way we reduce the number of times objects are created or released.EA Server offers Object Pooling for components deployed to EA server. When this option is turned on for a component, the object instances are pooled before returning to memory.EA Server/PB settings that effect Pooling
Our application uses object pooling option available in EA Server. This option is external to the PB language and is part of EA Server administration. The settings are available in component Properties -> Instances tab in Jaguar Manager.

Below setting enables Pooling for a component in EA Server, if checked.

Component Properties br_pay_business_rules_2011-05-19_08-14-57 Fig 1: This defines if pooling needs to be used for a particular object.

Below settings for the component in EA Server define how and when Pooling of the object can take place. As mentioned in the note, an object instance is kept in the pool only if it doesn’t exceed maximum setting. In this case, the pool will have at least 3 instances at any time. By adjusting these settings we can optimize the memory handling for the object. Too low setting for the minimum will cause more frequent garbage collection and too high will keep too many instances in the pool, thus wasting memory.

On the other hand, “Maximum Pooled Instances” setting effects how many can be kept in the pool. In a scenario where this object is constantly requested, increasing maximum setting will help. Again, this also means too many will be sitting in the pool during idle times.

Component Properties br_pay_business_rules_instance_pooling
Fig 2:
These settings define how instances of the object are pooled.

PB settings for Pooling
The below PB settings only decide if the releasing of object reference from PB side is automatic or manual. These settings are set at the component level in EAServer Component Generator (Project Painter).

The actual pooling is effected by the settings on the EA Server side, as mentioned above.

properties-for-easerver-component-generator_2011-05-19_08-44-43
Fig 3: This shows the settings on the PB side.

EA Server object instance life cycle

Below image is a capture of a visio diagram (attached) that attempts to show how pooling plays a role when objects are created from Powerbuilder code. As mentioned, Auto demarcation affects how the object references are released (automatic or manual) on the PB side.

When pooling is enabled for the object on the EA Server side (see Fig1), once the references are released the object instance is typically qualified for garbage collection.

If pooling is enabled, the object instance is then returned to Object Pool in EA Server, if the other conditions are met (see Fig 2).

latax_easerver_object_pooling.png

Fig 4: Object Life Cycle during a method call in our PB/EAServer Application

And here is what our typical Batch program Object pooling looks like

latax_interface_objects_handling

References:

Fig 5: Object Life Cycle during a method call in our Java/PB based Batch program

http://en.wikipedia.org/wiki/Memory_pool

http://en.wikipedia.org/wiki/Object_pool_pattern
http://www.javaworld.com/jw-06-1998/jw-06-object-pool.html
http://www.codeproject.com/KB/cpp/MemoryPoolIntroduction.aspx
http://mikebarlotta.sys-con.com/node/42163/

http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.dc38004_0610/html/eassolig/BABICABG.htm
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.dc38004_0610/html/eassolig/BABICABG.htm


Comments, please?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: