Why does Blazor server app takes away memory while being inactive?

Balu Raju 76 Reputation points
2023-02-07T13:44:18.7166667+00:00

We developed a Blazor server app and is going through testing phase. Our clients have some concern.

What we notice is that before the app is launched memory is 4784 K, one the app is launched and at the end of rendering the login page it is already over 50K.

Now staying on the login page and doing nothing with the app the memory in task manager keeps climbing up. When I see the IIS log, there is no activity at all, ever since login page is loaded.

Our clients see this as security risk and requesting an explanation.

Could someone shed some light on this memory usage of Blazor Server App, Why the memory usage is increasing.in task manager.

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,385 questions
{count} votes

5 answers

Sort by: Most helpful
  1. Balu Raju 76 Reputation points
    2023-02-07T21:21:05.89+00:00

    Thanks AGaveJoe, My comment on the line you quoted is that I was trying to differentiate between API calls I make vs Bruce's mention of "Internal Blazor Request" that IIS log do not see it, whereas my API calls are seen in IIS log. then I know something is going on.

    What I'm seeing is that all my web API Calls are done, the page is rendered completely and there are no other background tasks or something going on. However, I see the memory shooting up in Task Manager for quite some time. After significant increase for a while - say 5-8 minutes after page is rendered and not doing anything, the memory increase stops and remains stable until I go to different page.

    Bottom line,

    • All web API Calls are done
    • Page is rendered and waiting for my input/action.
    • There are no code that runs in the background anymore
    • There are no IIS logs entry

    At this time I expect memory increase should stop no matter how much memory it took away already. However, I see the memory kept increasing for a while say 5-8 minutes to very significant number and then it stops and remains stable.

    On a side note, we use three third party packages, Telerik UI for Blazor, MudBlazor, and Mobsites.Blazor.SignaturPad, and Dapper(? I Need to see why it is here)

    1 person found this answer helpful.

  2. Bruce (SqlWork.com) 55,601 Reputation points
    2023-02-07T18:10:16.0066667+00:00

    with blazor server apps, every active blazor user has a dedicated thread and memory for each signal/r connection. the first blazer request page loads the app. the app will not shutdown until the user navigates to a new (non-blazer) page.

    IIS will only see the load the app request (blazer.server.js) none of the internal blazor page requests are logged by IIS as it handled over the signal/r connection.

    0 comments No comments

  3. Balu Raju 76 Reputation points
    2023-02-07T18:20:53.7233333+00:00

    Thanks for the reply. As per your answer, even though I simply sat on the login page idle, and I watched the memory going up. You said "INternal Blazor Page " requests are not seen by IIS log.

    WHat are those requests as I do not have any requests that would be increasing the memory.

    Any request that I sent to goes through the another layer of .net Core API.

    SO I'm little puzzled about this internal Blazor Page requests.


  4. Bruce (SqlWork.com) 55,601 Reputation points
    2023-02-07T20:11:20.42+00:00

    as long as the blazor server app is active (loaded in browser) it running on the server. the blazor client is sending browser events to the server, and the server has a copy of the render-tree in memory along with all component parameters of the current render-tree.

    we can not see your code, it could be doing anything. maybe it made an api call and a blazor component parameter still has a reference to the results.

    when you navigate blazer pages, the client code sends the new route via signal/r to the dedicated blazer app connection (circuit). it builds a new render-tree and sends the updates back to the client. none of this traffic is visible to IIS logs.

    0 comments No comments

  5. Balu Raju 76 Reputation points
    2023-02-07T20:27:13.3166667+00:00

    Thanks again for the answer. Given that what you said in your second paragraph "we can not see your code, it could be doing anything. maybe it made an api call and a blazor component parameter still has a reference to the results." is not the case.

    Are there any security or other vulnerabilities that should be concerned with memory size going up,

    I noticed that after if shot up to significant memory , the memory sizing did stop and remain stable after about 5 minutes or so, when I was the only user on the site idling on the logon page doing nothing.

    0 comments No comments