<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>embedded C++: manage a resource with a tiny* object</title><link>/technologies/code_exchange/b/blog/posts/embedded-c-manage-a-resource-with-a-tiny-object</link><description>*tiny like in: 0 bits of data, 0 code instructions added, 0 clock ticks
scenario: you have a resource that needs to be initialised before use, and deactivated when done. We usually do that by calling some code before the actions, and some code after </description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: embedded C++: manage a resource with a tiny* object</title><link>https://community.element14.com/technologies/code_exchange/b/blog/posts/embedded-c-manage-a-resource-with-a-tiny-object</link><pubDate>Sun, 06 Apr 2025 13:21:26 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:56e5a225-6240-4bee-be45-25b443d1a6f0</guid><dc:creator>balajivan1995</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Even in my company we are advised to use SBRM (Scope based/bound resource management, as explained in original post example). Lifetime of the variables/object created inside the scope will be cleared once it goes out of scope.&lt;/p&gt;
&lt;p&gt;It does make code look ugly though.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=28815&amp;AppID=74&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: embedded C++: manage a resource with a tiny* object</title><link>https://community.element14.com/technologies/code_exchange/b/blog/posts/embedded-c-manage-a-resource-with-a-tiny-object</link><pubDate>Sat, 05 Apr 2025 19:14:42 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:56e5a225-6240-4bee-be45-25b443d1a6f0</guid><dc:creator>DAB</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;I like it.&lt;/p&gt;
&lt;p&gt;Many people forget that peripheral equipment need to be carefully activated and put away.&lt;/p&gt;
&lt;p&gt;If not, you can get some very unwanted effects or even life threatening consequences.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=28815&amp;AppID=74&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: embedded C++: manage a resource with a tiny* object</title><link>https://community.element14.com/technologies/code_exchange/b/blog/posts/embedded-c-manage-a-resource-with-a-tiny-object</link><pubDate>Sat, 05 Apr 2025 13:29:32 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:56e5a225-6240-4bee-be45-25b443d1a6f0</guid><dc:creator>Jan Cumps</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Pre-empting the question: but how much overhead?&lt;/p&gt;
&lt;p&gt;&lt;img height="257" src="/resized-image/__size/1000x514/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-56e5a225-6240-4bee-be45-25b443d1a6f0/pastedimage1743861135365v1.png" width="500" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;none.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The &amp;quot;nop&amp;quot; calls are there to&amp;nbsp;&amp;quot;do something&amp;quot; so that the optimiser doesn&amp;#39;t completely remove this example code.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=28815&amp;AppID=74&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: embedded C++: manage a resource with a tiny* object</title><link>https://community.element14.com/technologies/code_exchange/b/blog/posts/embedded-c-manage-a-resource-with-a-tiny-object</link><pubDate>Sat, 05 Apr 2025 13:18:49 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:56e5a225-6240-4bee-be45-25b443d1a6f0</guid><dc:creator>embeddedguy</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;Not yet sure about this feature but what about malloc() and free() at latter point of time? Is it not that effective anymore against memory leaks?&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=28815&amp;AppID=74&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item></channel></rss>