<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: delete, operator delete() and NULL pointers</title>
	<link>https://codesynthesis.com/~boris/blog//2008/11/17/delete-and-null-pointers/</link>
	<description>Boris Kolpackov's blog about software</description>
	<pubDate>Tue, 07 Apr 2026 09:02:29 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>

	<item>
		<title>By: Boris Kolpackov</title>
		<link>https://codesynthesis.com/~boris/blog//2008/11/17/delete-and-null-pointers/#comment-546</link>
		<author>Boris Kolpackov</author>
		<pubDate>Tue, 09 Dec 2008 03:39:59 +0000</pubDate>
		<guid>https://codesynthesis.com/~boris/blog//2008/11/17/delete-and-null-pointers/#comment-546</guid>
		<description>Francesco,

You can use one either depending on the semantics of the code. If you are allocating a "type-less" memory  block then using operator new()/delete() might be a good idea to convey this. On the other hand, if you are allocating an array of some objects then using the new/delete expressions is a more straightforward way. In some cases, like in the buffer example above, you can reasonably use either one.

As for how to detect the performance penalty, one would normally use a profiler. I use oprofile on GNU/Linux. If operator delete() is called very often, the profiler output will show that. The point in knowing the difference between the delete-expression and operator delete() before profiling is that you may be implementing a library, for example a memory buffer, that other applications will use. And you cannot predict what other applications will do with it. Some may construct and destroy a lot of empty buffers.

Boris</description>
		<content:encoded><![CDATA[<p>Francesco,</p>
<p>You can use one either depending on the semantics of the code. If you are allocating a &#8220;type-less&#8221; memory  block then using operator new()/delete() might be a good idea to convey this. On the other hand, if you are allocating an array of some objects then using the new/delete expressions is a more straightforward way. In some cases, like in the buffer example above, you can reasonably use either one.</p>
<p>As for how to detect the performance penalty, one would normally use a profiler. I use oprofile on GNU/Linux. If operator delete() is called very often, the profiler output will show that. The point in knowing the difference between the delete-expression and operator delete() before profiling is that you may be implementing a library, for example a memory buffer, that other applications will use. And you cannot predict what other applications will do with it. Some may construct and destroy a lot of empty buffers.</p>
<p>Boris</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Francesco</title>
		<link>https://codesynthesis.com/~boris/blog//2008/11/17/delete-and-null-pointers/#comment-544</link>
		<author>Francesco</author>
		<pubDate>Mon, 08 Dec 2008 15:37:04 +0000</pubDate>
		<guid>https://codesynthesis.com/~boris/blog//2008/11/17/delete-and-null-pointers/#comment-544</guid>
		<description>Hi Boris,
I found your blog today, I was looking for information about rvalue references. I will study your two posts about them, but in the meanwhile I would like to ask you a question about this post.

First of all, the conclusion appears to me that it's better to use the first form  (delete expression)  rather than the second (operator delete): by checking earlier we avoid the unneeded call. Am I right?

The second question is more general: How can you obtain a reliable measure if this subtle modification really makes a difference in an existing program? This is not something that you can test with a simple snippet. What kind of profiling tool/technique do you suggest for such a measurement?

Thanks in advance,
Francesco</description>
		<content:encoded><![CDATA[<p>Hi Boris,<br />
I found your blog today, I was looking for information about rvalue references. I will study your two posts about them, but in the meanwhile I would like to ask you a question about this post.</p>
<p>First of all, the conclusion appears to me that it&#8217;s better to use the first form  (delete expression)  rather than the second (operator delete): by checking earlier we avoid the unneeded call. Am I right?</p>
<p>The second question is more general: How can you obtain a reliable measure if this subtle modification really makes a difference in an existing program? This is not something that you can test with a simple snippet. What kind of profiling tool/technique do you suggest for such a measurement?</p>
<p>Thanks in advance,<br />
Francesco</p>
]]></content:encoded>
	</item>
</channel>
</rss>
