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.

Overview of Navigational Access<br />

Garbage Collection in the Object Cache<br />

The object cache has two important parameters associated with it which are<br />

properties of environment handle:<br />

■ maximum cache size<br />

■ 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 make memory available.<br />

If the amount of memory occupied by the objects that are currently in the cache<br />

reaches or exceeds the high water mark, then the cache automatically begins to free<br />

unmarked objects that have a pin count of 0. The cache continues freeing such<br />

objects until memory use in the cache is optimized, or until there are no more<br />

objects in the cache that are eligible for freeing.<br />

OCCI provides set and get methods in environments that allow you to set and get<br />

the cache maximum/optimal sizes. The maximum cache size is specified as a<br />

percentage of cache optimal size. The maximum cache size in bytes is computed as<br />

follows:<br />

maximum_cache_size = optimal_size + optimal_size * max_size_percentage/100<br />

The default value for cache maximum size is 10% and the default value for cache<br />

optimal size is 8MB. When a persistent object is created through the overloaded<br />

PObject::new operator, the newly created object is marked dirty and its pin count<br />

is 0.<br />

"Pin Object" on page 3-11 describes how pin count of an object functions as a<br />

reference count and how an unmarked object with a 0 pin count can become eligible<br />

for garbage collection. In the case of a newly created persistent object, the object is<br />

unmarked after the transaction is committed or aborted and if the object has a 0 pin<br />

count, in other words there are no references referring to it. The object then becomes<br />

a candidate for being aged out.<br />

Transactional Consistency of References<br />

As described in the previous section, dereferencing a Ref for the first time<br />

results in the object being loaded into the object cache from the database server.<br />

From then on, the behavior of operator -> on Ref is the same as any <strong>C++</strong><br />

pointer and it provides access to the object copy in the cache. But once the<br />

transaction commits or aborts, the object copy in the cache can no longer be valid<br />

because it could be modified by any other client. Therefore, after the transaction<br />

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

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

Saved successfully!

Ooh no, something went wrong!