AnsweredAssumed Answered

Memory leak in AttachmentInfo.GetDataAsync method

Question asked by MarcoAmine on Mar 26, 2018
Latest reply on Mar 27, 2018 by MarcoAmine

Hi,

I have a WPF application using runtime 10.2.7

In the application I run something like this:

   public async void Test()
   {
      var geodatabase = await Geodatabase.OpenAsync("path");

      var featureTable = geodatabase.FeatureTables.First((table => table.Name == "t"));

      foreach (var updatedFeatureId in featureTable.GetUpdatedFeatureIDs())
      {
         var feature = await featureTable.QueryAsync(updatedFeatureId);

         var attachments = await featureTable.QueryAttachmentsAsync(updatedFeatureId);

         if (attachments.Infos != null)
         {
            foreach (var attachmentInfo in attachments.Infos)
            {
               using (var fileStream = await attachmentInfo.GetDataAsync())
               {

                  // do something with file content
                  fileStream.Close();
                  fileStream.Dispose();
               }
            }
         }
      }
   }

 

When I run this with my offline .geodatabase file, the memory goes up to 1 GB (I have around 260 attachments of 4 Mb each), but it's never released.

 

Is this a known issue?

Is there any solution?

 

Just for curiosity I made a button that execute:

GC.Collect();

GC.WaitForPendingFinalizers();

This frees the memory but only when I press it twice.

 

Thanks in advance.

Best regards,

Marco

Outcomes