<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments for DelphiTools.info</title>
	<atom:link href="http://delphitools.info/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://delphitools.info</link>
	<description>SamplingProfiler and other Delphi tools</description>
	<lastBuildDate>Fri, 12 Feb 2010 12:53:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Comment on Don&#8217;t abuse FreeAndNil anymore by Bart van der Werf</title>
		<link>http://delphitools.info/2010/02/06/dont-abuse-freeandnil-anymore/comment-page-1/#comment-662</link>
		<dc:creator>Bart van der Werf</dc:creator>
		<pubDate>Fri, 12 Feb 2010 12:53:21 +0000</pubDate>
		<guid isPermaLink="false">http://delphitools.info/?p=433#comment-662</guid>
		<description>Alternatively something we do is hook FreeInstance to change the v-table pointer on the heapobject just before the FreeMemory call inside it.
This causes all virtual method calls on the now freed object to throw a CalledAMethodOnAFreedObject exception when the memory hasn&#039;t yet been reused or pageprotected.
The overhead is neglectible and works without replacing .Free or FreeAndNil calls.</description>
		<content:encoded><![CDATA[<p>Alternatively something we do is hook FreeInstance to change the v-table pointer on the heapobject just before the FreeMemory call inside it.<br />
This causes all virtual method calls on the now freed object to throw a CalledAMethodOnAFreedObject exception when the memory hasn&#8217;t yet been reused or pageprotected.<br />
The overhead is neglectible and works without replacing .Free or FreeAndNil calls.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Don&#8217;t abuse FreeAndNil anymore by Eric</title>
		<link>http://delphitools.info/2010/02/06/dont-abuse-freeandnil-anymore/comment-page-1/#comment-661</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Mon, 08 Feb 2010 07:31:29 +0000</pubDate>
		<guid isPermaLink="false">http://delphitools.info/?p=433#comment-661</guid>
		<description>&gt;NIL’ing the reference can also be valid in it’s own right.

Indeed, this why there is a need to distinguish between valid scenarios and abuses.

&gt;In a destructor, a partially destructed object may conceivably be re-destroyed.

I strongly disagree there: yes, some object reference can be FreeAndNil&#039;ed multiple times during as part of their design during an owner context lifetime, but that should never happen during a destruction chain. If it does happen, then you&#039;re facing either redundant or spaghetti code, with poor maintainability and higher risk of divergence.

Separating FreeAndNil and FreeAndInvalidate allows to make that distinction between a normal nil reference situation, and an abnormal one.

&gt; Any objects Free’d during execution of the previous partial destructor chain obviously should not be re-freed.

Indeed, but FreeAndNil is not a protection against that: a field will stay nil ONLY if the memory of the context that hosted the reference isn&#039;t reallocated during the destruction chain, something you just can&#039;t guarantee in a destruction chain (especially in multi-threading situations). 
This can (and does) lead to code initially &quot;working&quot; in single-threaded situations, that very randomly goes bonkers in multi-threading situations, or after some allocations get mixed in the destruction chain ...like allocations arising from debug code added to diagnose the very random bonkers situations just mentioned!

&gt;More realistically there may be “instantiate on demand” references

In that case use FreeAndNil, that&#039;s what it&#039;s for.
For all the other situations (IME the vast majority of cases), there is no need to abuse FreeAndNil, and one should never forget that FreeAndNil/FreeAndInvalidate are nothing more than optimistic defensive strategies, so fix the design, that saves pains down the road. :)</description>
		<content:encoded><![CDATA[<p>>NIL’ing the reference can also be valid in it’s own right.</p>
<p>Indeed, this why there is a need to distinguish between valid scenarios and abuses.</p>
<p>>In a destructor, a partially destructed object may conceivably be re-destroyed.</p>
<p>I strongly disagree there: yes, some object reference can be FreeAndNil&#8217;ed multiple times during as part of their design during an owner context lifetime, but that should never happen during a destruction chain. If it does happen, then you&#8217;re facing either redundant or spaghetti code, with poor maintainability and higher risk of divergence.</p>
<p>Separating FreeAndNil and FreeAndInvalidate allows to make that distinction between a normal nil reference situation, and an abnormal one.</p>
<p>> Any objects Free’d during execution of the previous partial destructor chain obviously should not be re-freed.</p>
<p>Indeed, but FreeAndNil is not a protection against that: a field will stay nil ONLY if the memory of the context that hosted the reference isn&#8217;t reallocated during the destruction chain, something you just can&#8217;t guarantee in a destruction chain (especially in multi-threading situations).<br />
This can (and does) lead to code initially &#8220;working&#8221; in single-threaded situations, that very randomly goes bonkers in multi-threading situations, or after some allocations get mixed in the destruction chain &#8230;like allocations arising from debug code added to diagnose the very random bonkers situations just mentioned!</p>
<p>>More realistically there may be “instantiate on demand” references</p>
<p>In that case use FreeAndNil, that&#8217;s what it&#8217;s for.<br />
For all the other situations (IME the vast majority of cases), there is no need to abuse FreeAndNil, and one should never forget that FreeAndNil/FreeAndInvalidate are nothing more than optimistic defensive strategies, so fix the design, that saves pains down the road. <img src='http://delphitools.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Don&#8217;t abuse FreeAndNil anymore by Rudy Velthuis</title>
		<link>http://delphitools.info/2010/02/06/dont-abuse-freeandnil-anymore/comment-page-1/#comment-660</link>
		<dc:creator>Rudy Velthuis</dc:creator>
		<pubDate>Sun, 07 Feb 2010 21:31:34 +0000</pubDate>
		<guid isPermaLink="false">http://delphitools.info/?p=433#comment-660</guid>
		<description>&#124; thus leaving a invalid reference that should however never be used
&#124; anymore when the code design is correct

I would say: &quot;thus leaving an invalid reference that CAN however never be used anymore.&quot; This does not require FreeAndNil, nor does it need anything like FreeAndInvalidate, IMO.</description>
		<content:encoded><![CDATA[<p>| thus leaving a invalid reference that should however never be used<br />
| anymore when the code design is correct</p>
<p>I would say: &#8220;thus leaving an invalid reference that CAN however never be used anymore.&#8221; This does not require FreeAndNil, nor does it need anything like FreeAndInvalidate, IMO.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Don&#8217;t abuse FreeAndNil anymore by Jolyon Smith</title>
		<link>http://delphitools.info/2010/02/06/dont-abuse-freeandnil-anymore/comment-page-1/#comment-659</link>
		<dc:creator>Jolyon Smith</dc:creator>
		<pubDate>Sun, 07 Feb 2010 19:56:00 +0000</pubDate>
		<guid isPermaLink="false">http://delphitools.info/?p=433#comment-659</guid>
		<description>Sorry, but this conflates two problems and discards a perfectly valid strategy simply because it only addresses ONE of those problems.

FreeAndNIL() isn&#039;t always about NIL&#039;ing a reference to an object and hoping that an AV will result if that reference is subsequently re-used.  NIL&#039;ing the reference can also be valid in it&#039;s own right.

In a destructor, a partially destructed object may conceivably be re-destroyed.  Any objects Free&#039;d during execution of the previous partial destructor chain obviously should not be re-freed.

Yes, a partially destroyed object indicates a potential problem in that class or it&#039;s design, but still may be a valid/unavoidable scenario.

More realistically there may be &quot;instantiate on demand&quot; references that are periodically disposed of, but not replaced until needed.  NIL&#039;ing those references when disposed creates a testable condition to trigger the creation of a new object if subsequently referenced.

This sort of thinking process coming out of Embarcadero is illuminating.  It seems to indicate to me that the guys &quot;running the show&quot; behind Delphi these days are less concerned about practical work and getting a job of work done, and more interested in abstract language and coding theory and practises.

Sad.</description>
		<content:encoded><![CDATA[<p>Sorry, but this conflates two problems and discards a perfectly valid strategy simply because it only addresses ONE of those problems.</p>
<p>FreeAndNIL() isn&#8217;t always about NIL&#8217;ing a reference to an object and hoping that an AV will result if that reference is subsequently re-used.  NIL&#8217;ing the reference can also be valid in it&#8217;s own right.</p>
<p>In a destructor, a partially destructed object may conceivably be re-destroyed.  Any objects Free&#8217;d during execution of the previous partial destructor chain obviously should not be re-freed.</p>
<p>Yes, a partially destroyed object indicates a potential problem in that class or it&#8217;s design, but still may be a valid/unavoidable scenario.</p>
<p>More realistically there may be &#8220;instantiate on demand&#8221; references that are periodically disposed of, but not replaced until needed.  NIL&#8217;ing those references when disposed creates a testable condition to trigger the creation of a new object if subsequently referenced.</p>
<p>This sort of thinking process coming out of Embarcadero is illuminating.  It seems to indicate to me that the guys &#8220;running the show&#8221; behind Delphi these days are less concerned about practical work and getting a job of work done, and more interested in abstract language and coding theory and practises.</p>
<p>Sad.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Don&#8217;t abuse FreeAndNil anymore by Eric</title>
		<link>http://delphitools.info/2010/02/06/dont-abuse-freeandnil-anymore/comment-page-1/#comment-658</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Sun, 07 Feb 2010 13:14:51 +0000</pubDate>
		<guid isPermaLink="false">http://delphitools.info/?p=433#comment-658</guid>
		<description>It&#039;s no magic bullet, and they could do it (and likely will), sure, but then it can be pointed to as an explicit design error, while using FreeAndNil / Assigned aren&#039;t by themselves explicit errors.
Nil is a &quot;valid&quot; value for an object reference, and with Assigned(), there are valid design and usage case scenarios. There exists no such scenario for an AssignedInvalid function, so you can shoot on sight whoever comes up with one, something you can&#039;t do for FreeAndNil/Assigned.

It&#039;s all about moving the issue from a gray area, to one of black and white.</description>
		<content:encoded><![CDATA[<p>It&#8217;s no magic bullet, and they could do it (and likely will), sure, but then it can be pointed to as an explicit design error, while using FreeAndNil / Assigned aren&#8217;t by themselves explicit errors.<br />
Nil is a &#8220;valid&#8221; value for an object reference, and with Assigned(), there are valid design and usage case scenarios. There exists no such scenario for an AssignedInvalid function, so you can shoot on sight whoever comes up with one, something you can&#8217;t do for FreeAndNil/Assigned.</p>
<p>It&#8217;s all about moving the issue from a gray area, to one of black and white.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Don&#8217;t abuse FreeAndNil anymore by Christian Wimmer</title>
		<link>http://delphitools.info/2010/02/06/dont-abuse-freeandnil-anymore/comment-page-1/#comment-657</link>
		<dc:creator>Christian Wimmer</dc:creator>
		<pubDate>Sun, 07 Feb 2010 01:43:04 +0000</pubDate>
		<guid isPermaLink="false">http://delphitools.info/?p=433#comment-657</guid>
		<description>I think moving from memory address 0 (nil) to 1 is only moving the problem to another memory address. The next step people will do is to create an AssignedInvalid function (people tend to be pragmatic) that checks for such an invalid object. And history repeats itself.</description>
		<content:encoded><![CDATA[<p>I think moving from memory address 0 (nil) to 1 is only moving the problem to another memory address. The next step people will do is to create an AssignedInvalid function (people tend to be pragmatic) that checks for such an invalid object. And history repeats itself.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on SamplingProfiler v1.7.4 by Mike Dunlavey</title>
		<link>http://delphitools.info/2009/09/08/samplingprofiler-v1-7-4/comment-page-1/#comment-158</link>
		<dc:creator>Mike Dunlavey</dc:creator>
		<pubDate>Mon, 21 Dec 2009 14:44:57 +0000</pubDate>
		<guid isPermaLink="false">http://delphitools.info/?p=428#comment-158</guid>
		<description>I just stumbled onto this site from StackOverflow. I can&#039;t tell, from the description of SamplingProfiler, what it actually samples. I hope it samples the call stack, and I hope it samples it on wall-clock time, not throwing away samples that occur during I/O that the thread has requested. I&#039;m sure you understand that the fractional cost of any line of code is nicely estimated by the fraction of samples it appears on, and that recursion is a non-issue.</description>
		<content:encoded><![CDATA[<p>I just stumbled onto this site from StackOverflow. I can&#8217;t tell, from the description of SamplingProfiler, what it actually samples. I hope it samples the call stack, and I hope it samples it on wall-clock time, not throwing away samples that occur during I/O that the thread has requested. I&#8217;m sure you understand that the fractional cost of any line of code is nicely estimated by the fraction of samples it appears on, and that recursion is a non-issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on SamplingProfiler v1.7.4 by utku</title>
		<link>http://delphitools.info/2009/09/08/samplingprofiler-v1-7-4/comment-page-1/#comment-155</link>
		<dc:creator>utku</dc:creator>
		<pubDate>Sat, 05 Dec 2009 09:07:55 +0000</pubDate>
		<guid isPermaLink="false">http://delphitools.info/?p=428#comment-155</guid>
		<description>Eric, FYI, the profiler doesn&#039;t seem to work under &quot;Start Sampling Immediately&quot; mode. Other modes are okay. (This is Delphi 2010, Windows 7.)</description>
		<content:encoded><![CDATA[<p>Eric, FYI, the profiler doesn&#8217;t seem to work under &#8220;Start Sampling Immediately&#8221; mode. Other modes are okay. (This is Delphi 2010, Windows 7.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on SamplingProfiler v1.7.3 bug fix by Eric</title>
		<link>http://delphitools.info/2009/05/22/samplingprofiler-v173-bug-fix/comment-page-1/#comment-149</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Thu, 13 Aug 2009 09:33:09 +0000</pubDate>
		<guid isPermaLink="false">http://delphitools.info/?p=409#comment-149</guid>
		<description>Started a topic in the forum
http://delphitools.info/forums/index.php?topic=16.0
Should make it easier to keep track of the progress and details</description>
		<content:encoded><![CDATA[<p>Started a topic in the forum<br />
<a href="http://delphitools.info/forums/index.php?topic=16.0" rel="nofollow">http://delphitools.info/forums/index.php?topic=16.0</a><br />
Should make it easier to keep track of the progress and details</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on SamplingProfiler v1.7.3 bug fix by Peter</title>
		<link>http://delphitools.info/2009/05/22/samplingprofiler-v173-bug-fix/comment-page-1/#comment-148</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Sun, 26 Jul 2009 02:51:13 +0000</pubDate>
		<guid isPermaLink="false">http://delphitools.info/?p=409#comment-148</guid>
		<description>Sampling Profiler v1.7.3 is only showing ntdll.dll with 1 samples in all of my projects.
Im using Delphi 2009 on Windows 7 64 Bit.
MAP information found and no settings changed…

How to fix that?</description>
		<content:encoded><![CDATA[<p>Sampling Profiler v1.7.3 is only showing ntdll.dll with 1 samples in all of my projects.<br />
Im using Delphi 2009 on Windows 7 64 Bit.<br />
MAP information found and no settings changed…</p>
<p>How to fix that?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
