<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Disposing objects. in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/disposing-objects/m-p/3619208#M57760</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I only have the German version of Visual Studio, but translated the window should have a name like "output" (while you are in debug-mode),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HTH, - alfred -&lt;/P&gt;</description>
    <pubDate>Thu, 13 Sep 2012 17:55:57 GMT</pubDate>
    <dc:creator>Alfred.NESWADBA</dc:creator>
    <dc:date>2012-09-13T17:55:57Z</dc:date>
    <item>
      <title>Disposing objects.</title>
      <link>https://forums.autodesk.com/t5/net-forum/disposing-objects/m-p/3284567#M57757</link>
      <description>&lt;P&gt;Hello forum,&lt;/P&gt;&lt;P&gt;I'd like to know which objects I should dispose and which not (using c#):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;objDatabase = MdiActiveDocument.Database;&lt;BR /&gt;// I do not have to dispose a reference to database of active document.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using (objTransaction = objDatabase.TransactionManager.StartTransaction())&lt;BR /&gt;// using statement disposes transaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;objBlockTable = (BlockTable)objTransaction.GetObject(objDatabase.BlockTableId, OpenMode.ForRead);&lt;BR /&gt;// When done with objBlockTable, am I suppose to call Dispose?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;objBlockTableRecord = (BlockTableRecord)objTransaction.GetObject(objDatabase.CurrentSpaceId, OpenMode.ForWrite);&lt;BR /&gt;// When done with objBlockTableRecord, I am suppose to call Dispose?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;objBlockReference = new BlockReference(new Point3d(objPointResult.Value.X, objPointResult.Value.Y, 0), structObjectId);&lt;BR /&gt;...&lt;BR /&gt;objBlockTableRecord.AppendEntity(objBlockReference);&lt;BR /&gt;// When done with objBlockReference, I am suppose to call Dispose?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Jan 2012 12:08:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/disposing-objects/m-p/3284567#M57757</guid>
      <dc:creator>Ertqwa</dc:creator>
      <dc:date>2012-01-07T12:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: Disposing objects.</title>
      <link>https://forums.autodesk.com/t5/net-forum/disposing-objects/m-p/3284573#M57758</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the most simple rule is (worked well for the last years for me):&lt;/P&gt;&lt;P&gt;any object you create and has afterwards to be cleaned from memory has to be disposed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Samples for &lt;FONT color="#666699" face="lucida sans unicode,lucida sans"&gt;.Dispose&lt;/FONT&gt; needed:&lt;/U&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;if you create a virtual line for calculating intersectionpoints, but you don't add this line to the database you have to free up memory by disposing it.&lt;/LI&gt;&lt;LI&gt;If you create a transaction object you have to free the memory from it after using it (just as additional info: the &lt;FONT color="#666699" face="lucida sans unicode,lucida sans"&gt;using (transaction-object)&lt;/FONT&gt; statement includes the &lt;FONT color="#666699" face="lucida sans unicode,lucida sans"&gt;.Dispose&lt;/FONT&gt; internally)&lt;/LI&gt;&lt;LI&gt;Same for DocumentLock ... if you created such an object you have to dispose it (in this case to unlock the document).&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#666699" face="lucida sans unicode,lucida sans"&gt;.Dispose&lt;/FONT&gt; is not needed for objects that does also exist after your code has finished&lt;/P&gt;&lt;P&gt;&lt;U&gt;Samples for &lt;FONT color="#666699" face="lucida sans unicode,lucida sans"&gt;.Dispose&lt;/FONT&gt; NOT needed:&lt;/U&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;BlockTableRecord, LayerTableRecord Line/Circle/Arc/... geometric objects if they are appended to the database or already did exist in the database. These objects exists also after your code finished .... so you don't need to clean up the memory for these objects (because AutoCAD itself uses them)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know this is a version of a primitive global statment, but for starting it works great:&lt;/P&gt;&lt;P&gt;"&lt;FONT color="#808080"&gt;&lt;EM&gt;If objects should be alive after your code finished, don't .Dispose, it objects where just created virtually and not database resident they should be disposed&lt;/EM&gt;&lt;/FONT&gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another help is VisualStudio in debug-mode: when you run your app in debug mode you can look at the window (within VisualStudio) where messages where send to. Because when you .Dispose transactions (or at the end of &lt;FONT color="#666699" face="lucida sans unicode,lucida sans"&gt;using&lt;/FONT&gt;) AutoCAD sends you the message if you forgot to dispose something.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HTH, - alfred -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Jan 2012 12:51:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/disposing-objects/m-p/3284573#M57758</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2012-01-07T12:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: Disposing objects.</title>
      <link>https://forums.autodesk.com/t5/net-forum/disposing-objects/m-p/3619056#M57759</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alfred or anyone how know - which window allow me to see this message of forgotten non-disposed objects?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2012 16:14:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/disposing-objects/m-p/3619056#M57759</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-09-13T16:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: Disposing objects.</title>
      <link>https://forums.autodesk.com/t5/net-forum/disposing-objects/m-p/3619208#M57760</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I only have the German version of Visual Studio, but translated the window should have a name like "output" (while you are in debug-mode),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HTH, - alfred -&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2012 17:55:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/disposing-objects/m-p/3619208#M57760</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2012-09-13T17:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: Disposing objects.</title>
      <link>https://forums.autodesk.com/t5/net-forum/disposing-objects/m-p/3628184#M57761</link>
      <description>&lt;P&gt;Look at the &lt;EM&gt;&lt;STRONG&gt;AutoDelete&lt;/STRONG&gt;&lt;/EM&gt; property of any object that derives from &lt;EM&gt;DisposableWrapper&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the value of that property is false, that means the object will do nothing when it is disposed, which means that it doesn't need to be disposed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2012 19:13:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/disposing-objects/m-p/3628184#M57761</guid>
      <dc:creator>DiningPhilosopher</dc:creator>
      <dc:date>2012-09-20T19:13:10Z</dc:date>
    </item>
  </channel>
</rss>

