问题描述

在创建App Service服务的时候,根据定价层不同,内存使用的最大值也有不同。但在实际测试中,发现内存最大只能占用2GB左右,

而定价层中内存分配明明是大于2GB(比如B3定价层的内存为7GB), 这是一种什么情况呢?

在App Service中Kudu工具上,查看进程分配的内存大小:

问题解答

使用一段简短C#代码来进行验证,代码是一个循环,根据URL中输入的数字,循环创建多个100MB大小的对象.

var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
var app = builder.Build(); app.MapGet("/oom/{objs}", (string objs) =>
{
int objunmbers = int.Parse(objs);
try
{
byte[][] largeArray = new byte[objunmbers][];
for (int i = 0; i < objunmbers; i++)
{
largeArray[i] = new byte[1024 * 1024 * 100]; // 每个对象占用100MB
}
return "成功创建大数组对象: " + objs;
}
catch (OutOfMemoryException)
{
return "内存不足,无法创建大数组对象";
}
}); app.Run();

代码本地调试,可以看见应用占用内存直线上涨:

部署到Azure App Service后,同样通过Kudu站点Process信息,发现内存的占用的确只有2GB左右,但请求需要更多内存资源时,页面返回:内存不足,无法创建大数组对象

这是因为App Service for Windows默认使用32位操作系统,最大内存只能分配2GB。

当主动修改位64位后,App Service 内存就可以占用到定价层所允许的最大值!

如B3的定价层在Kudu中查看到w3wp.exe进程分配的内存达到了6GB

根据以上测验,当使用App Service内存没有达到预期的值,且应用异常日志出现OutOfMemory时,就需要检查Platform的设置是否位64bit。

 

参考资料

I see the message "Worker Process requested recycle due to 'Percent Memory' limit." How do I address this issue? 

https://learn.microsoft.com/en-us/troubleshoot/azure/app-service/web-apps-performance-faqs#i-see-the-message-worker-process-requested-recycle-due-to-percent-memory-limit-how-do-i-address-this-issue

The maximum available amount of memory for a 32-bit process (even on a 64-bit operating system) is 2 GB. By default, the worker process is set to 32-bit in App Service (for compatibility with legacy web applications).

Consider switching to 64-bit processes so you can take advantage of the additional memory available in your Web Worker role. This triggers a web app restart, so schedule accordingly.

Also note that a 64-bit environment requires a Basic or Standard service plan. Free and Shared plans always run in a 32-bit environment.

【Azure App Service】在App Service for Windows上验证能占用的内存最大值的更多相关文章

  1. Windows上验证过的一些乱七八糟的笔记

    1.Win10安装时报错“windows 无法安装到这个磁盘 gpt分区形式”? 答:shift+f10:  https://jingyan.baidu.com/article/08b6a591c82 ...

  2. windows上使用SecureCRT连接linux

    前言: SecureCRT是一款支持SSH(SSH1和SSH2)的终端仿真程序,简单地说是Windows下登录UNIX或Linux服务器主机的软件.这样操作的时候不必进入到linux桌面,可以更方便的 ...

  3. node-webkit教程(7)Platform Service之APP

    node-webkit教程(7)Platform Service之APP 文/玄魂 前言 几个月前,要开发一个简易的展示应用,要求支持离线播放(桌面应用)和在线播放(web应用). 当时第一想到的是f ...

  4. 【应用服务 App Service】App Service发生错误请求时,如何查看IIS Freb日志,从中得知错误所发生的模块,请求中所携带的Header信息

    问题描述 在使用Azure App Service时候,我们有时候对 一些请求发生错误毫无头绪,能从错误代码中知道请求错误,但是更多的信息呢? 当我们需要更多的信息时候,通常有以下的一些方式来查找问题 ...

  5. android如何实现开机自动启动Service或app

    第一步:首先创建一个广播接收者,重构其抽象方法 onReceive(Context context, Intent intent),在其中启动你想要启动的Service或app. import and ...

  6. [Windows Azure] What is a cloud service?

    What is a cloud service? When you create an application and run it in Windows Azure, the code and co ...

  7. 【转】android如何实现开机自动启动Service或app

    1.今天我们主要来探讨android怎么让一个service开机自动启动功能的实现.Android手机在启动的过程中会触发一个Standard Broadcast Action,名字叫android. ...

  8. 在Azure上部署IPv6的App通过IOS App Store审核

    随着中国企业出海Go Global,越来越多的用户开始在Global Azure部署自己的应用.由于对Global Azure功能和文档的不熟悉,使用过程中或多或少遇到了一些坑.事实上呢,这些并不是坑 ...

  9. 不可或缺 Windows Native (25) - C++: windows app native, android app native, ios app native

    [源码下载] 不可或缺 Windows Native (25) - C++: windows app native, android app native, ios app native 作者:web ...

  10. 004.Create a web app with ASP.NET Core MVC using Visual Studio on Windows --【在 windows上用VS创建mvc web app】

    Create a web app with ASP.NET Core MVC using Visual Studio on Windows 在 windows上用VS创建mvc web app 201 ...

随机推荐

  1. 线性dp:最长公共子串

    最长公共子串 本文讲解的题与leetcode718.最长重复子数组,题意一模一样,阅读完本文以后可以去挑战这题. 力扣链接 题目叙述: 给定两个字符串,输出其最长公共子串的长度. 输入 ABACCB ...

  2. 组合逻辑环(Combinational Logic Loop)

    组合逻辑电路 组合逻辑电路是数字电子学中一类基本的电路类型,它由一系列逻辑门组成,用于实现特定的逻辑功能.与时序逻辑电路不同,组合逻辑电路的输出完全取决于当前的输入信号,而不受之前输入的影响.换句话说 ...

  3. Ubuntu 配置默认编辑器

    在 Ubuntu 系统中,可以通过多种方式配置默认的文本编辑器,以便在使用命令行工具(如 crontab 或 visudo)时自动使用你喜欢的编辑器.以下是几种常见的方法: 使用 update-alt ...

  4. vscode新建html文件并快速生成标准的html代码

    1.打开vscode,点击Open Folder 2.选择目标文件夹,新建一个扩展名为.html的文件: 3.在第一行输入 !(英文状态下),按tab键,新建成功.界面如下图所示:

  5. airflow 学习

    入门 Get started developing workflows with Apache Airflow Getting started with Apache Airflow  

  6. Go实现常用的排序算法

    一.插入排序 1.从第一个元素开始,该元素可以认为已经被排序 2.取出下一个元素,在已经排序的元素序列中从后向前扫描 3.如果该元素(已排序)大于新元素,将该元素移到下一位置 4.重复步骤3,直到找到 ...

  7. python之re库,正则表达

    一.前言 为什么要学re库呢?这里主要学他的正则表达,在编写安全脚本的时候肯定要遇到一些不规则的匹配规则,当然编写爬虫也少不了正则匹配去找到一些具有特殊特征的字符串.因此这是十分必要的,然而.re库使 ...

  8. 画流程图、状态图、时序图、甘特图的JS库-mermaid-js

    参考地址:https://github.com/mermaid-js/mermaid 原生使用方式: <!DOCTYPE html> <html> <head> & ...

  9. 【原创】解决NasCab掉进程,NasCab进程维护

    最近对象吐槽家里服务器又连不上,看不了考研视频了. 我掏出手机一试,确实连不上.家里的服务器是Win11平台,用NasCab管理的视频文件,然后通过frpc做的内网穿透. 我们在外面的图书馆,连不上无 ...

  10. C++ const常量指针

    const常量指针 const是C++关键字,译为常量,const指针即为常量指针. 分为三类 指向const的指针 const指针 指向const的const指针 指向const的指针 表示指向区域 ...