10.12.2012 Views

Oracle C++ Call Interface Programmer's Guide

Oracle C++ Call Interface Programmer's Guide

Oracle C++ Call Interface Programmer's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Developing an OCCI Object Application<br />

reference is dereferenced for the first time and decremented when the reference<br />

goes out of scope. When the pin count of the object becomes 0, indicating that all<br />

references to that object are out of scope, the object is automatically eligible for<br />

garbage collection and subsequently deleted from the cache.<br />

For persistent objects that have been created by calling the new operator, you must<br />

call a delete if you do not commit the transaction. Otherwise, the object is garbage<br />

collected after the commit. This is because when such an object is created using new,<br />

its pin count is initially 0. However, because the object is dirty it remains in the<br />

cache. After a commit, it is no longer dirty and thus garbage collected. Therefore, a<br />

delete is not required.<br />

If a commit is not performed, then you must explicitly call delete to destroy that<br />

object. You can do this as long as there are no references to that object. For transient<br />

objects, you must delete explicitly to destroy the object.<br />

You should not call a delete operator on a persistent object. A persistent object that<br />

is not marked/dirty is freed by the garbage collector when its pin count is 0.<br />

However, for transient objects you must delete explicitly to destroy the object.<br />

Tuning the Object Cache<br />

The object cache has two important associated parameters:<br />

■ The maximum cache size percentage<br />

■ The optimal cache size<br />

These parameters refer to levels of cache memory usage, and they help to determine<br />

when the cache automatically "ages out" eligible objects to free up memory.<br />

If the memory occupied by the objects currently in the cache reaches or exceeds the<br />

maximum cache size, the cache automatically begins to free (or age out) unmarked<br />

objects which have a pin count of zero. The cache continues freeing such objects<br />

until memory usage in the cache reaches the optimal size, or until it runs out of<br />

objects eligible for freeing.<br />

The maximum object cache size (in bytes) is computed by incrementing the optimal<br />

cache size (optimal_size) by the maximum cache size percentage (max_size_<br />

percentage), as follows:<br />

3-12 <strong>Oracle</strong> <strong>C++</strong> <strong>Call</strong> <strong>Interface</strong> Programmer’s <strong>Guide</strong><br />

Note: The cache can grow beyond the specified maximum cache<br />

size.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!