High memory usage on loading a SFDT Document


I'm trying to use the DocIO to replace the content of some word documents (template) with user input.
The user input is taken using the DocumentEditorContainer (for Angular). This data is taken in sfdt format itself and sent to our ASP service for doing the replacement.

When the service starts up the memory usage is as low as 30MB. 

The attached zip file has two sample sfdt files.

When we try to open the small.sfdt as a word document (using Syncfusion.EJ2.DocumentEditor.WordDocument) the usage jumps up to 60MB
When we try to open the big.sfdt as a word document the usage jumps up to 340MB

The does not drop after the file is closed/request has ended.

Since multiple such files can be included in a single request, our service easily crosses 2GB of memory usage and at some point new requests will fail due to lack of memory.

The below sample code is enough to show the 


using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Syncfusion.EJ2.DocumentEditor;

namespace Test.Controllers
{
[ApiController]
[Route("[controller]")]
public class SfdtController : ControllerBase
{

[HttpPost]
[Route("docx")]
public IActionResult Test([FromBody] Input input)
{
foreach (var sfdt in input.Content)
{

using var stream =
WordDocument.Save(sfdt, FormatType.Docx);
}
return Content("");
}
public class Input
{
public ICollection<string> Content { get; set; }
}
}
}
Either the is a memory leak somewhere or we're handling sfdt documents incorrectly, either way some advice would be helpful.

Attachment: debug_96e11c68.7z

10 Replies 1 reply marked as answer

SM Suriya Murugan Syncfusion Team May 28, 2021 10:35 AM UTC

Hi Robert, 

Syncfusion Greetings! 

Currently, we are checking the provided sfdt and will update you further details by May 31,2021. 

Regards, 
Suriya M. 



KB Kurthis Banu Abdul Majeeth Syncfusion Team May 31, 2021 03:36 PM UTC

Hi Robert,  

Sorry for inconvenience caused. 

Currently, we are checking your reported issue. We will update you further details by June 1,2021.  

Regards,  
Kurthis Banu A.  



KB Kurthis Banu Abdul Majeeth Syncfusion Team June 1, 2021 05:21 PM UTC

Hi Robert,  

Regarding: memory leak 

We are validating the reported issue and get back to you further details by June 3,2021. 

Regards, 
Kurthis Banu A. 



KB Kurthis Banu Abdul Majeeth Syncfusion Team June 3, 2021 01:54 PM UTC

Hi Robert,   


Regarding: memory leak  


On further validation. We suspect the issue because of you haven’t dispose the stream in your application. 

Kindly dispose the stream for both open(import) and save(export) methods in your application like below code snippet to reduce the memory usage. 


Code snippet: 

stream.Dispose(); 
document.Dispose(); 
fileStream.Close(); 


Please let us know if you are still facing issue. 


Regards,  
Kurthis Banu A.  


Marked as answer

NI Nicholas August 25, 2021 01:25 PM UTC

 I would like to confirm that there is 100% a leak in the SF code here. I have a piece of code that just converts an sfdt string to a word document and then instantly closes and disposes of the word doc and every time this piece of code is run it adds another 200mb of overhead to my memory usage. Code is below. Also this editor has decided it do

string sfdtText = "";using (Stream docStream = _docStorageProvider.LoadDocument(section.FileId)){using (StreamReader reader = new StreamReader(docStream, Encoding.UTF8)){sfdtText = reader.ReadToEnd();}}
#warning possible memory leak//SFDT to .docxvar wordDoc = Syncfusion.EJ2.DocumentEditor.WordDocument.Save(sfdtText);wordDoc.Close();wordDoc.Dispose();


SM Suriya Murugan Syncfusion Team August 26, 2021 07:10 AM UTC

Hi Nicolas, 
 
1.      Can you please share your Blazor documenteditor version details? If you were using lower version(less than 19.2.0.57), Please upgrade your packages to latest version and ensure the same. 
 
2.      Also, confirm are facing issue for specific document or all document? if specific document, please share the document, that will be helpful for us to proceed further and provide you solution at earliest. 
 
3.      If possible, share the vido demonstration to show case memory leak. 
 
Regards, 
Suriya M. 



NI Nicholas August 26, 2021 09:24 AM UTC

I can confirm that i am using version 19.2.0.57. 

I can also confirm that this issue can happen with many documents but the easiest way to recreate it and the one that creates the most obvious leak is to create a sfdt file with a large image in it and then try to convert that to a word file using the method from my previous comment. To be specific i used this image https://images.hdqwalls.com/download/moon-stars-dark-10k-d3-7680x4320.jpg converting that file caused me to go from about 200mb of memory usage to 1.2GB and then the usage will steadily rise at a much slower pace if the process is repeated

Also i cannot share the original file used as it contains confidential conf



SM Suriya Murugan Syncfusion Team August 27, 2021 11:52 AM UTC

Hi Nicholas, 
  
Currently, we are checking the reported case and will update further details by August 31,2021. 
  
Regards, 
Suriya M. 



SM Suriya Murugan Syncfusion Team September 1, 2021 03:39 AM UTC

Hi Nicholas, 
  
Sorry for the inconvenient caused. 
  
We will check and update details by September 1,2021. 
  
Regards, 
Suriya M. 



SM Suriya Murugan Syncfusion Team September 2, 2021 03:37 AM UTC

Hi Nicholas,  

Please clear cache and try the same steps. 

In version 19.2.0.57, we didn’t face memory leak. 

If you are facing, please share video illustration to demonstrate memory leak. 

Regards, 
Suriya M. 


Loader.
Up arrow icon