<?xml version="1.0" encoding="windows-1252"?>
<node id="1014145" title="Re: Timing of garbage collection" created="2013-01-18 17:19:53" updated="2013-01-18 17:19:53">
<type id="11">
note</type>
<author id="647953">
sundialsvc4</author>
<data>
<field name="doctext">
&lt;p&gt;
When I read this post, I zeroed in on: &amp;nbsp; &lt;i&gt;So, &lt;b&gt;&amp;ldquo;I need to be sure that&lt;/b&gt; when I get rid of an object of this class, the cleanup happens immediately.&amp;rdquo;&lt;/i&gt; &amp;nbsp;
And my strong recommendation is: &amp;nbsp; &amp;ldquo;find a way not to have to care about that.&amp;rdquo;
&lt;/p&gt;&lt;p&gt;
Reading further, I see that the core problem is that, to this application, &amp;ldquo;keys&amp;rdquo; are actually not &lt;em&gt;&amp;ldquo;temporally&lt;/em&gt; unique&amp;rdquo; at all. &amp;nbsp; As the OP says, &amp;ldquo;the same key may come back fairly soon.&amp;rdquo; &amp;nbsp; The application obviously has no control over this: &amp;nbsp; the key, in other words, whatever it may be, is originating from &lt;i&gt;the business.&lt;/i&gt;
&lt;/p&gt;&lt;p&gt;
When something like this happens ... and it does happen a lot in the real world ... I normally solve the problem by treating these &amp;ldquo;external&amp;rdquo; keys as &lt;i&gt;surrogate keys.&lt;/i&gt; &amp;nbsp; I do not use them to &amp;ldquo;uniquely&amp;rdquo; identify the records that the application must store, knowing that (for my technical purposes) they might not be unique. &amp;nbsp; Instead, I generate truly-unique, internal-only keys for the records that I need to store, and I &lt;em&gt;map&lt;/em&gt; the business-provided keys to them.
&lt;/p&gt;&lt;p&gt;
Very importantly: &amp;nbsp; it may well be that there is &lt;em&gt;not&lt;/em&gt; a &amp;ldquo;one-to-one relationship&amp;rdquo; between the business-provided keys and my internal, known to be &lt;i&gt;really-&lt;/i&gt;unique, mappings. &amp;nbsp; (Should be ... &lt;em&gt;&amp;ldquo;always&amp;rdquo; swear-to god-and hope-to die &lt;u&gt;should&lt;/u&gt; be&lt;/em&gt; ... but there ain&amp;rsquo;t.) &amp;nbsp; And so, ever so much &lt;u&gt;more&lt;/u&gt; importantly, in spite of this &amp;ldquo;inconvenient truth,&amp;rdquo; my application nevertheless did &lt;b&gt;not&lt;/b&gt; fall-down and burn in some kind of &amp;ldquo;I never thought this could happen to me&amp;rdquo; heap. &amp;nbsp; The business might have screwed-up, but I&amp;rsquo;m still standin&amp;rsquo;. &amp;nbsp; &lt;i&gt;&amp;ldquo;Priceless.&amp;rdquo;&lt;/i&gt;
&lt;/p&gt;&lt;p&gt;
Business-provided identifiers do all sorts of weird things in real life, because &lt;em&gt;human beings&lt;/em&gt; are responsible for every bit of it. &amp;nbsp; Well, humans can deal with that sort of thing; computers can&amp;rsquo;t. &amp;nbsp; So, you have to find a way that the computer &lt;em&gt;can,&lt;/em&gt; because in any argument between the computer and a human, the computer is the one that has to budge.
&lt;/p&gt;&lt;p&gt;
Even when designing the internal storage architecture, I try to avoid having many references-to the same &amp;ldquo;storage object.&amp;rdquo; &amp;nbsp; Instead, I assign each object a (application-generated, not disclosed to anyone) random truly-unique key, and refer to it elsewhere using that key. &amp;nbsp; Yes, that involves an additional hash-lookup.
&lt;/p&gt;&lt;p&gt;
If the business&amp;rsquo;s way of handling &amp;ldquo;an identifier&amp;rdquo; is posing problems to your application ... don&amp;rsquo;t try to fancy-pants program around it: &amp;nbsp; instead, &lt;em&gt;map&lt;/em&gt; what you are given to something else (which you give to no one) which &lt;em&gt;does&lt;/em&gt; meet the computer&amp;rsquo;s requirements. &amp;nbsp; Whatever you do, stay on your feet.
&lt;/p&gt;</field>
<field name="root_node">
1014100</field>
<field name="parent_node">
1014100</field>
</data>
</node>
