I have created a function for exporting to the las in the geometry range by the ILasDataset.Export method.now every time the function when it is called,it takes some memory,but doesn't release that much, meaning on every function call a memory leak happens. **The program has crashed when calling this method about 8,000 times.**Following is the minimal code version of this behaviour:
public static bool ExportLasFromAE(ILasDatasetLayer lasdLayer, IGeometry geometry, string lasSavePath, bool overwrite)
{
using (ESRI.ArcGIS.ADF.ComReleaser pComReleaser = new ESRI.ArcGIS.ADF.ComReleaser())
{
ILasDataset pLasDataset = lasdLayer.Dataset;
ITrackCancel pCancel = null;
ILasFilter pLasFilter = new LasFilterClass();
pComReleaser.ManageLifetime(pLasFilter);
pLasFilter.AreaOfInterest = geometry;
ISpatialReference pSpatialReference = lasdLayer.Dataset.SpatialReference;
string pFileDirectory = System.IO.Path.GetDirectoryName(lasSavePath);
string pFileName = System.IO.Path.GetFileNameWithoutExtension(lasSavePath);
string pFileExtensionName = System.IO.Path.GetExtension(lasSavePath);
//IEnvelope pGeometryEnvelop = geometry.Envelope;
IRelationalOperator pRelationalOperator = geometry as IRelationalOperator;
for (int i = 0; i < pLasDataset.FileCount; i++)
{
ILasFile pLasFile = pLasDataset.get_File(i);
IEnvelope pLasFileEnvelope = pLasFile.Extent;
if (pRelationalOperator.Disjoint(pLasFileEnvelope))
{
continue;
}
int pFileIndex = i;
string pFilePath = string.Format("{0}//{1}_{2}{3}", pFileDirectory, pFileName, i.ToString(), pFileExtensionName);
if (File.Exists(pFilePath))
{
if (overwrite)
{
File.Delete(pFilePath);
}
else
{
continue;
}
}
pLasDataset.Export(pCancel, pFileIndex, pLasFilter, pFilePath, pSpatialReference, false, false);
}
}
return true;
}