would the memory pointed by auto_ptr leak in case of neven ending application?
<p>I need to run an application in an embedded system continuously. While implementing this application, i need to allocate lot of memory from Heap. If i use auto_ptr for those, when will that be freed ? As per my understanding, memory pointed by auto pointers would be freed upon exiting/terminating the application. It would not be freed automatically if application is not exited.
I can use reset() to free the memory like below.</p>

<pre><code>auto_ptr&lt;Test&gt; testPtr(new Test);
testPtr.reset();
</code></pre>

<p>But then, the purpose of auto_ptr would be defeated if i do this. If i can do reset() at all places, i can do delete also at all the places.</p>

<p>Pls let me know whether memory pointed by auto_ptr would get freed even though application is not exited. If not, is there any otherway to freeup the memory, other than calling reset() ?</p>

<p>EDIT: In my case, auto_ptr is inside a class. That class object will be destroyed only upon exiting the application. As the application runs infinitely, class object will not be destroyed. Hence the issue. Pls consider this also.</p>

<p>EDIT: Answer: As i am using same auto_ptr for storing other objects, everytime i do assignment, auto_ptr assignment operator would take care of deleting previous object. So no leak even without call to reset.</p>
