.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Are Data inside Xrecord really Disposed ?

1 REPLY 1
Reply
Message 1 of 2
bikelink
311 Views, 1 Reply

Are Data inside Xrecord really Disposed ?

This is a snippet of my code used to remove an Xrecord
I loop also an add Xrecord (same dictionary ecc..) and i've tried to force a GC.Collect after this but the system memory increased
Why the memory increased ? after the first Add i supposed it's remain constants (first delete --> after add )
I check the memory in Task Manager


// The Main loop is
for (int k = 0; k < 100000; k++)
{
SetDATAXRecord(mydocument, mydataset);
}


void SetDATAXRecord(Document d, Dataset ds)
{
// the first time this skip and return..
b2XRec.deleteEntryXRecordFromDictionary("mydictname", "mylabel");
// add xrecord...
b2XRec.setDatasetInXrecord(ds, "mydictname", "mylabel");
GC.Collect();
}


public static bool deleteEntryXRecordFromDictionary(string dictionaryName, string nameEntry)
{
ObjectId idremoved = ObjectId.Null;

DBDictionary mioDizionario = null;
using (DocumentLock docLock = m_document.LockDocument())
{
SetDbFromDocument();
using (Transaction trans = db.TransactionManager.StartTransaction())
{
try
{
// First, get the NOD...
using (DBDictionary dict = (DBDictionary)trans.GetObject(db.NamedObjectsDictionaryId, OpenMode.ForWrite))
{
if (dict.Contains(dictionaryName))
{
ObjectId idXrecDict = dict.GetAt(dictionaryName);
mioDizionario = (DBDictionary)trans.GetObject(idXrecDict, OpenMode.ForWrite);


if (mioDizionario.Contains(nameEntry))
{
idremoved = mioDizionario.Remove(nameEntry);
using (Xrecord pEnt = (Xrecord)trans.GetObject(idremoved, OpenMode.ForWrite, false, true))
{
pEnt.Erase();
}
}
mioDizionario.Erase();
// mioDizionario.ReleaseExtensionDictionary();
trans.Commit();

}
}
}
catch (Autodesk.AutoCAD.Runtime.Exception e)
{
MessageBox.Show(e.Message);
trans.Abort();
return false;
}
}
}
return (idremoved != ObjectId.Null);
}

Edited by: bikelink on Mar 24, 2010 8:31 AM Edited by: bikelink on Mar 24, 2010 8:44 AM
1 REPLY 1
Message 2 of 2
bikelink
in reply to: bikelink

Thanks to Daniel (theswamp.org) to resolve this problem.
xrec.Data = new ResultBuffer()

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost