Memory Leak - Streams never disposed of?

Hi guys -

The project I'm working on involves uploading hundreds of images at a time. I've noticed that the memory consumption in the browser just continues to grow and grow, until eventually it takes up upwards of 2GB RAM. The total size of the uploads is 1.5GB, about 600 photos, so it seems like the files are loaded into memory on the client application, but they are never garbage collected or disposed of. When I refresh the tab, the memory usage goes back down to about 250MB, and it increases every time a file is uploaded.

I am using Async upload with a Blazor server side API endpoint. Everything else works as I expect, just the memory usage is going to cause issues when users start uploading 4GB folders or larger (due to processor constraints).

I'm not sure what more information you would find helpful. I think this issue is present even on the simplest of SfUploader configurations and it seemed to be the same when I wasn't using Async settings.

I've actually just realized that at some point the browser tab gets capped on memory and the UploadSuccess calls don't end up getting called, so it's a pretty serious issue. Is there any way I can clear the upload list manually or remove files from memory once they have been uploaded?

I think you can reproduce this by uploading any large file or set of files.

Thanks,

Tharon


6 Replies

PM Ponmani Murugaiyan Syncfusion Team November 8, 2021 12:37 PM UTC

Hi Tharon, 

Thanks for contacting Syncfusion support. 

Currently we are checking your reported query. We will update further details in 2 business days (November 10, 2021).  We appreciate your patience until then. 

Regards, 
Ponmani M 



BC Berly Christopher Syncfusion Team November 10, 2021 03:34 PM UTC

Hi Tharon, 
  
We can clear the uploader file list in the UI manually by calling the public method named as “ClearAllAsync” as mentioned in the below code example. Else, we can clear the file list from the UI with help of clear or remove button in the Uploader component. 
  
  public void OnClick() 
    { 
 
        UploadObj.ClearAllAsync(); 
    } 
 
  
  
Also, we can remove the already uploaded file from the stored destination with help of below code. Here, we have removed the already uploaded file in the OnRemove event which is triggered while clicking the delete icon of the file list. 
  
  private void onRemove(RemovingEventArgs args) 
    { 
        foreach(var removeFile in args.FilesData) 
        { 
            if (File.Exists(Path.Combine(@"D:\VS\Blazor\Blazor_Server\Blazor_Server",  @"path" + removeFile.Name))) ; 
            { 
                File.Delete(Path.Combine(@"D:\VS\Blazor\Blazor_Server\Blazor_Server", @"path" + removeFile.Name)); 
            } 
        } 
    } 
 
  
  
  
Still facing issue, then share any issue reproducing sample along with video demonstration that will help us to check and proceed further from our end. 
  
Regards, 
Berly B.C 



TR Tharon Rodriguez November 23, 2021 02:40 PM UTC

I will create a sample for you shortly and upload for your review. 


Thanks! 



BC Berly Christopher Syncfusion Team November 24, 2021 07:36 AM UTC

Hi Tharon, 
  
We will wait until hear from you. 
  
Regards, 
Berly B.C 



TR Tharon Rodriguez December 1, 2021 03:54 PM UTC

Hi -- I have attached a project sample to demonstrate the issue. Here is a quick folder with some screenshots of the issue 


1 : The apps tarts up and takes up about 100MB. https://drive.google.com/file/d/1S_Orb0tWreKMFJRQOGwKtFJAk1TChbee/view?usp=sharing

2. Select a lot of images. In this example there are about 550 images, totaling 1.16GB. The memory usage goes to 160MB, still pretty reasonable https://drive.google.com/file/d/11rCueLaIQVJsKKcmfwheYHt5dbIM6UBO/view?usp=sharing

3. I started the upload. The application quickly consumes as much memory as it can, jumping to 1.9GB, and crushing the browser, it's basically unresponsive https://drive.google.com/file/d/1_EzmOq9UPHW3DbHGQnPB8a7WVAiPKRDQ/view?usp=sharing

4. The upload completes, and I cleared the Upload List using the default Clear button (I believe this calls ClearAllAsync()). The memory usage stays the same. https://drive.google.com/file/d/1H0qL07jC-nLr0Uiv-gkd5Znq3Nm5dHNv/view?usp=sharing

5, 6. Select a different folder to upload, the memory stays the same: 
https://drive.google.com/file/d/1mZdCX-PQC61LOq2HR2pAdArOTd5ZN2FZ/view?usp=sharing
https://drive.google.com/file/d/1dx2FS65TqFgJZxS4_q4WLhttaElPxG_l/view?usp=sharing

7. When I click "Upload", memory drops back down to ~250MB, until the upload starts and the new files are loaded into memory: https://drive.google.com/file/d/1ZzHBqsK9jlYTtTvYKUvZcrFOaQ6Aj0sa/view?usp=sharing


A couple thoughts --- 

  • Can we limit the number of concurrent uploads so that the uploader doesn't consume all available memory? Maybe queueing the files then sending them in batches would be more appropriate :)
  • Is there a better way to clear files from memory once they have been uploaded?

I was incorrect about one thing - the failure to raise the OnSuccess event were due to the Upload Endpoint being overwhelmed which results in excessively long response times. 

Let me know if you need more information!

Attachment: SfUploaderDemo_42e22ed8.zip


BC Berly Christopher Syncfusion Team December 2, 2021 12:13 PM UTC

Hi Tharon, 
  
By default, Uploader component will process multiple the files in the uploader component simultaneously. So, we suggest you to enable sequential upload feature which helps you to upload files one by one. Please refer the below link to know more about this feature. 
  
  
As we mentioned earlier, we suggest you to use our RemoveAsync() method which is help you to remove all the uploaded files from the server. 
  
  
Regards, 
Berly B.C 


Loader.
Up arrow icon