Extreme memory leaks

Hello. I finally put the app in production server and it turns nightmare.
For each client the app set app pool nearly 2 GB, and this memory is never returned. A few hours later the whole memory is consumed and server is stuck.
To see what I mean - you can even test it with Sidebar demo example.
Open the example run it on .NET 3.1 and run the memory profiler. start clicking fast just the button to show/hide the sidebar. It will take about 1/4 MB each time, and this memory will never be returned.
As many component you set - the worse it will become.

22 Replies

SP Sowmiya Padmanaban Syncfusion Team January 4, 2021 03:12 PM UTC

Hi Yordon,  
 
We have checked your reported memory leak issue in sidebar with menu component. Please refer to the attached  video. 
 
 
Memory is constantly maintained during expand and collapsing of Sidebar component. 
 
Could you please share the below details to proceed further with your reported problem. 
 
1.     Share us the video footage of your reported problem. 
2.     What are the Syncfusion components used inside the Sidebar component? 
3.     Are you performing any operations on expand and collapse of Sidebar component? If yes, share the details. 
 
Please let us know, if you need any further assistance. 
 
Regards,  
Sowmiya.P 



YO Yordan January 4, 2021 06:37 PM UTC

Put it on production IIS.
Run the server. Go to Application pool. Start working with any of the components. Connect more peoples to the side. Look what's hapen with the application pool.
But even with a since sidebar the memory will only increase.


KR Keerthana Rajendran Syncfusion Team January 5, 2021 12:21 PM UTC

Hi Yordon,   
 
Thanks for the update.  
 
Please update the list of Blazor Syncfusion components used in your application and the list of components in which you face memory leaks issue. This will be helpful for us to validate those components by hosting in IIS and assist you promptly. 
 
Regards, 
Keerthana.  



YO Yordan January 5, 2021 04:22 PM UTC

It is practically if not with all, then the most of the components.
You can try to put a treeview with let say 3000 elements, each of the elements let have picture which is 100kb JPEG.
Then put this treeview inside a sidebar, and open and close the sidebar a few times. observe the application pool


YO Yordan January 7, 2021 09:34 PM UTC

Here. I've made a simple example. 
Try it to see the application pool and memory issues.
.



Attachment: SyncfusionBlazorApp32_566d3237.rar


MD Molier de Ritoi January 8, 2021 07:21 AM UTC

I have similar problem. 
The whole thing lag after about 30 users, and server freeze from too much RAM usage, but my server have only 16 GB of ram.


SP Sowmiya Padmanaban Syncfusion Team January 8, 2021 12:29 PM UTC

Hi Yordon,  
 
We are able to replicate your reported problem with TreeView component. Currently, we are validating on this problem. We will update the validation details within two business days on 12th January 2021. 
 
We appreciate your patience. 
 
Regards,  
Sowmiya.P 



YO Yordan January 8, 2021 12:33 PM UTC

Dear support - there is more components affected. I presume it's not only about the treeview.


SP Sowmiya Padmanaban Syncfusion Team January 11, 2021 09:39 AM UTC

Hi Yordon,  
 
Currently, we are validating your reported problem using Sidebar with TreeView component. Please update the list of Blazor Syncfusion components used in your application and the list of components in which you face memory leaks issue. This will be helpful for us to validate those components and provide you the details at the earliest. 
 
Please let us know, if you need any further assistance. 
 
Regards,  
Sowmiya.P 
  



KR Keerthana Rajendran Syncfusion Team January 12, 2021 11:48 AM UTC

Hi Yordan, 
  
A support incident to track the status of this defect has been created under your account. Please log on to our support website to check for further updates  
  
  
Regards, 
Keerthana.  
 



MI Michal February 12, 2021 10:18 PM UTC

Same memory problem is with:
SfGrid
Memory is still rising up, with every grid data refresh, ram never gets released (using binding with ExpandoObject, because direct use of dicionary is not supported).
- Leaving page with navigateto to another = ram persists full
- Staying at page and only refreshing gid data = ram raising
- GC doesnt release ram also
Every refresh eats arround 2MB of ram, +-1000 rows and 10 columns


It remains me SfGrid UWP xamarin forms - grid.cells was not released from reference. Maybe just random similarity :)


VN Vignesh Natarajan Syncfusion Team February 15, 2021 10:59 AM UTC

Hi Michal,  
 
Thanks for contacting Syncfusion support.  
 
Query: “Same memory problem is with: SfGrid Memory is still rising up, with every grid data refresh 
 
We have analyzed your query and we understand that you are facing memory leaks in Grid component upon refresh. We have improved and resolved the memory leaks in Grid component in most of the scenarios in our recent patch release. So we need some more details about the issue you are facing to validate the reported query at our end. Kindly share the following details.  
 
  1. Share the Grid rendering code example.
  2. Share details about your datasource bounded to Grid component.
  3. Share your Syncfusion.Blazor Nuget package details.
  4. Share the video demonstration of the issue along with replication procedure.  
  5. If possible share a simple sample to reproduce the reported issue at  our end.
 
Above requested details will be very helpful for us to validate the reported query at our end and provide solution as early as possible.  
 
Regards, 
Vignesh Natarajan 



MI Michal February 18, 2021 08:59 AM UTC

Hello Vignesh,
 thany you for your interest, here are the answers:

Share the Grid rendering code example.
RAZOR markup:

@if (Cols!=null && Cols.Count>0)
{
AllowPaging="true" Columns="@Cols" @ref="SGrid"
AllowSorting="true" AllowFiltering="true"
AllowExcelExport="true"
EnableVirtualization="false">
}
Share details about your datasource bounded to Grid component.
CS:
public List Cols;
public XeDataTable DataTable { get; set; }


protected override async Task OnInitializedAsync()
{
//await Task.Yield();
await RefreshGrid(SGrid, First);
}
private async Task RefreshGrid(SfGrid dataGrid, bool forced)
{
this.IsBusy = true;

try
{
if (First)
{ ....loading COLUMNS, actions etc. from  remote source

if (DataTable.GridModel != null) //dynamically build SfGrid columns when empty
{
if (Cols == null || Cols.Count == 0)
{

CreateGridColumns(DataTable);
}
}
await DataTable.LoadData(); // Load data ROWS from remote source
finally
{
this.IsBusy = false;
if (First == false)
SGrid.Refresh();//!! required when DataSource2 is NOT ObservableCollection (just List<>). When ObservableCollection is used, loading grid is SLOW,flickering....
}
First = false;
}
}
}
public async Task OnRefreshClick()
{
if (IsBusy) return;
await RefreshGrid(SGrid, false);
}
public void RowSelectingHandler(RowSelectingEventArgs args)
{
}
public void GridCommandClickHandler(CommandClickEventArgs args)
{
}

protected void CreateGridColumns(XeDataTable DataTable)
{
try
{
var columns = new List();
Cols = new List();
foreach (sDCol field in DataTable.FieldDefinitions)  //build all columns....
{
var column = new GridColumn
{
HeaderText = field.PubName,
Field = field.SysName,
FilterSettings = new FilterSettings() { Operator = Operator.Contains },
IsPrimaryKey = field.isUnique,
Visible = !field.isHidden,
AutoFit = true
};
if (field.DType == enDataType.Boolean)
{
column.DisplayAsCheckBox = true;
}
}
var columnact = new GridColumn
{
HeaderText = "Action",
AutoFit = false,
AllowFiltering = false,
AllowSorting = false,
Width = "60"//,IsFrozen=true//,AllowSearching=false
};
columnact.Commands = new List();
columnact.Commands.Add(new GridCommandColumn()
{
Title = "Action",
Type = CommandButtonType.None,
ButtonOption = new CommandButtonOptions()
{
//IconPosition=Syncfusion.Blazor.Buttons.IconPosition.Left, 
//Content="ABC",
IsPrimary = true,
IconCss = "e-icons e-edit",
CssClass = "e-flat"
}
});
columns.Insert(0, columnact);
Cols = columns; //assign colums
}
}
public void CustomizeCell(QueryCellInfoEventArgs args)
{
var data = args.Data;
if (args != null && args.Data != null)
{
List styles = new List();
// Grid row background color
var rowBgrColorData = args.Data.FirstOrDefault(x => x.Key.StartsWith(Constants.SysParRowColorBack));
if (rowBgrColorData.Value != null)
{
Color bgrColor = (Color)new ColorConverter().ConvertFromString(Convert.ToString(rowBgrColorData.Value));

styles.Add("background-color: " + "#" + bgrColor.R.ToString("X2") + bgrColor.G.ToString("X2") + bgrColor.B.ToString("X2"));
}

// Grid cell background color
string colfulll = Constants.SysParColColorBack + args.Column.Field;

var bgrColorData = args.Data.FirstOrDefault(x => x.Key == colfulll);
if (bgrColorData.Value != null)
{
Color bgrColor = (Color)new ColorConverter().ConvertFromString(Convert.ToString(bgrColorData.Value));

styles.Add("background-color: " + "#" + bgrColor.R.ToString("X2") + bgrColor.G.ToString("X2") + bgrColor.B.ToString("X2"));
}
if (styles.Count > 0)
{
args.Cell.AddStyle(styles.ToArray());
}
}
}

public class XeDataTable //: ObservableBase
{
private WE1App App { get; set; }
public XeDataTable(WE1App _app)
{
App = _app;
}

public IList FieldDefinitions { get; set; }

public DataRecordSource DataSource { get; set; }=new DataRecordSource();
public IEnumerable DataSource2 { get => DataSource; }
public class DataRecordSource : List //ObservableCollection was SLOW - when populating rows Dictionary cannot be used for SfGrid
{

}
}

Share your Syncfusion.Blazor Nuget package details.
Affected tested versions of 
Syncfusion.Blazor:
18.4.0.43 and 18.4.0.34


Share the video demonstration of the issue along with replication procedure. 
Attached

Attachment: sfgrid2_974af825.zip


MI Michal February 18, 2021 05:41 PM UTC

Attached text file for better code readibility

Attachment: sfgrid_757202a6.zip


VN Vignesh Natarajan Syncfusion Team February 24, 2021 03:39 AM UTC

Hi Michal,  

Thanks for sharing the requested details.  

Currently we are validating the reported issue by preparing a sample as per your code example. We will update you the further details in two business days.  

Till then we appreciate your patience.  

Regards, 
Vignesh Natarajan 



BV Bob Vale February 25, 2021 10:45 PM UTC

I don't know if it's of any help but we've just started noticing the memory leak problem too.

We are only running 18.2.0.59 release at the moment as we needed time to deal with the breaking changes in 18.3

I've finally caught a memory dump of when the server went nuts and it's  giving me extreme memory usages for 17,899,753 count taking 2,720,762,456 bytes..... This isn't even the true usage as VS is telling me "Due to the large number of objects a representative sample is being used".


AsyncTaskMethodBuilder+AsyncStateMAchineBox<VoidTaskResult,Syncfusion.Blazor.Internal.SfBaseUtils+<IsScriptRendered>d_5>


VN Vignesh Natarajan Syncfusion Team March 2, 2021 08:29 AM UTC

Hi Michal,  

Thanks for the patience.  

We have validated the reported issue by preparing a sample using your code example and we are able to reproduce the reported behavior at our end also. we have validated the reported issue further by comparing the snapshots in the diagnostic tools with Grid component and navigating away from it. We are able to find the instances of Grid after navigating to new page also. Refer the below screenshot for your reference. After navigating from Grid component also, its instances were not removed.   

 

We suggest you to resolve the reported issue by implementing the Dispose method of Blazor and dispose the Grid component inside it. Refer the below code example.  

@implements IDisposable 
 
<Button @onclick="OnRefreshClick">Refresh</Button> 
 
@if (Cols != null && Cols.Count > 0) 
{ 
    <SfGrid ID="SGrid" TValue="ExpandoObject" DataSource=@DataTable.DataSource2 
            AllowPaging="true" Columns="@Cols" @ref="SGrid" 
            AllowSorting="true" AllowFiltering="true" 
            AllowExcelExport="true" 
            EnableVirtualization="false"> 
        <GridEvents QueryCellInfo="CustomizeCell" RowSelecting="RowSelectingHandler" CommandClicked="GridCommandClickHandler" TValue="ExpandoObject"></GridEvents> 
        <GridFilterSettings EnableCaseSensitivity="false" IgnoreAccent="true" Mode="FilterBarMode.Immediate" ImmediateModeDelay="600"></GridFilterSettings> 
        <GridPageSettings PageSize="50"></GridPageSettings> 
    </SfGrid> 
} 
 
  
@code{ 
    SfGrid<ExpandoObject> SGrid { getset; } 
    public List<GridColumn> Cols; 
    public bool First { getset; } = true; 
    public XeDataTable DataTable { getset; } = new XeDataTable(); 
    public void Dispose() 
    { 
        SGrid.Dispose(); 
        SGrid = null; 
    } 

After implementing the above solution, we are able to remove the instances of Grid component after navigating, refer the below screenshot for your reference 

 

For your convenience we have attached the updated below  


Refer the below UG documentation for your reference 


Please get back to us if you have further queries.  

Regards, 
Vignesh Natarajan 




VN Vignesh Natarajan Syncfusion Team March 2, 2021 08:30 AM UTC

Hi Bob,  

Thanks for the update.  

From your query we understand that you are facing memory leaks in Grid component while using 18.2.0.59 Syncfusion.Blazor Nuget package. We would like to inform you that we have fixed the memory leaks in Grid component in various scenario in our latest version. So we request you to upgrade to our latest version by resolving the breaking changes we have introduced in various main releases.  

We kindly request you to ensure the reported issue after upgrading to our latest version. If you are still facing the reported after upgrading, kindly get back to us with more details.  

Regards, 
Vignesh Natarajan 



BV Bob Vale March 4, 2021 10:41 AM UTC

I finally upgraded to the 18 release.

Memory usage did seem to go, but then rapidly increased again, my problem is it's not consistent.  When it does happen it is a massive spike (multiple GB).  I'm currently downloading a memory dump to determine if it is the same or something else.

On the manual disposing of the grid, that is a lot of pages to implement it on, plus fun with nested components. If your workaround a temporary fix and you will be creating a fix inside the components in an upcoming release?



MI Michal March 4, 2021 10:52 AM UTC

Thanks Vignesh for idea with disposing, but its not the root of the problem:
1 page
1 grid
1 resfresh data button = keep cliclink on refresh button = "load data to grid" again and again and keep watching memory between 1 and 30 reloads/clicks. GC runs, but dont release memory. Do not mix "browser refresh page" with refresh data button on page.

Dispose grid on every datasource load/reload, is not possible scenario and you dont wont dispose something, that user actualy watching on page (datagrid) :)

Cannot confirm if its completely fixed in new version and real scenario, because in new version, the sfcharts are keep crasing(but thats another story). Will give you report as soon as possible.


VN Vignesh Natarajan Syncfusion Team March 9, 2021 01:04 PM UTC

Hi Michal / Bob,  
 
Thanks for the update.  
 
Query: “GC runs, but dont release memory. Do not mix "browser refresh page" with refresh data button on page. 
 
Currently we are validating the reported scenario at our end and we need some more time to analyze the query. So we will update you the further details in two business days.  
 
@Bob – In the previous update we have provided solution (SGrid == null) to remove the remaining instances of Grid while using the Ref property. We afraid it is not a workaround.    
 
Till then we appreciate your patience.   
 
Regards, 
Vignesh Natarajan  
 
 



VN Vignesh Natarajan Syncfusion Team March 15, 2021 10:41 AM UTC

Hi Michal,  
 
Thanks for the patience.  
 
Query: “GC runs, but dont release memory. Do not mix "browser refresh page" with refresh data button on page. 
 
We have validated the reported query and we are able to reproduce the reported behavior at our end also. We suggest you to use Collect method of GC (garbage collector) in the Refresh button click event  to resolve the reported issue.  
 
Refer the below code example   
 
private async Task RefreshGrid(SfGrid<ExpandoObject> dataGrid, bool forced) 
    { 
        try 
        { 
            . . . . . . . 
           //call below method while updating the grid data and refreshing.  
            GC.Collect(); 
        } 
        finally 
        { 
            if (First == false) 
            { 
                SGrid.Refresh();//!! required when DataSource2 is NOT ObservableCollection (just List<>). When ObservableCollection is used, loading grid is SLOW,flickering.... 
            } 
            First = false; 
        } 
    } 
 
Kindly download the modified sample from below  
 
 
Please get back to us with more details if you have further queries or if you are still facing the reported issue.  
 
Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon