- Home
- Forum
- ASP.NET Core - EJ 2
- High memory usage on loading a SFDT Document
High memory usage on loading a SFDT Document
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.
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
|
stream.Dispose();
document.Dispose();
fileStream.Close(); |
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();
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
- 10 Replies
- 4 Participants
- Marked answer
-
RT Robert Taylor
- May 27, 2021 03:52 PM UTC
- Sep 2, 2021 03:37 AM UTC