Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 864d1c3c3cd8df4e3a2692faf8776e05 > files > 1281

db4o-doc-7.4-2.fc13.i686.rpm

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Turning Off Weak References</title>
    <link rel="stylesheet" type="text/css" href="../../../style.css">
  </head>
  <body>
    <div class="CommonContent">
      <div class="CommonContentArea">
        <h1>Turning Off Weak References</h1><div id="TOC"><div id="TOCinner"><span class="TOCtitle">Contents</span><div class="TOCcontents"><ul><li><a href ="#Advantage">Advantage</a></li><li><a href ="#Effect">Effect</a></li><li><a href ="#Alternate Strategies">Alternate Strategies</a></li></ul></li></ul></div></div></div>



<span name="cs_wiki_filter" csw_filters="net">
<p>.NET: </p><p><code>Db4oFactory.Configure().WeakReferences(false)</code></p>
</span><a name="Advantage"></a><h2>Advantage</h2>
<p>will configure db4o to use hard direct references instead of weak references to control instantiated and stored objects.</p>

<a name="Effect"></a><h2>Effect</h2>
<p>A db4o database keeps a reference to all persistent objects that are currently held in RAM, whether they were stored to the database in this session or instantiated from the database in this session. This is how db4o can "know" than an object is to be updated: Any "known" object must be an update, any "unknown" object will be stored as "new". (Note that the reference system will only be in place as long as an ObjectContainer is open. Closing and reopening an ObjectContainer will clean the references system of the ObjectContainer and all objects in RAM will be treated as "new" afterwards.) In the default configuration db4o uses weak references and a dedicated thread to clean them up after objects have been garbage collected by the VM. Weak references need extra ressources and the cleanup thread will have a considerable impact on performance since it has to be synchronized with the normal operations within the ObjectContainer. Turning off weak references will improve speed. </p>
<p>The downside: To prevent memory consumption from growing consistantly, the application has to take care of removing unused objects from the db4o reference system by itself. This can be done by calling</p>


<span name="cs_wiki_filter" csw_filters="net">
<p>.NET: </p>
<p><code>IExtObjectContainer.Purge(object)</code></p>
</span>

<a name="Alternate Strategies"></a><h2>Alternate Strategies</h2>


<span name="cs_wiki_filter" csw_filters="net">
<p>.NET: </p><p><code>IExtObjectContainer.Purge(object)</code></p>
</span>
<p>can also be called in normal weak reference operation mode to remove an object from the reference cache. This will help to keep the reference tree as small as possible. After calling #purge(object) an object will be unknown to the ObjectContainer so this feature is also suitable for batch inserts. </p></div>
    </div>
    <div id="footer">
					This revision (9) was last Modified 2007-05-07T15:44:48 by Tetyana.
				</div>
  </body>
</html>