Azure function with App Service Plan keeps getting out of memory error at 1.8GB

Akeem Afuwape (CA) 0 Reputation points
2025-02-18T15:14:33.2166667+00:00

I have a durable function processing files from a blob storage as an activitiy. However, I seem to always run into out-of-memory error (Python 137) at about 1.8GB of memory use. I am using a Premium v3 P3V3 plan, so I expect i have sufficient memory to handle this task.

Question 1:
I have tried to optimize my code, what are my alternatives?

Question 2:
Max memory (GB per instance) varies between 1.75-256/8-256, how can choose a memory above 1.8GB.

Please note I am holding any data in memory, I am writing outputs to blob. The process runs fine in on my local machine.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,441 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,345 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ranashekar Guda 95 Reputation points Microsoft Vendor
    2025-02-18T16:50:27.4533333+00:00

    Hi @Akeem Afuwape (CA),
    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.

    To resolve your out-of-memory error (Python code 137) on Azure Functions with a Premium v3 P3V3 plan, consider the following alternatives:

    • Since you've optimized your code, consider profiling your function app to find memory bottlenecks. Tools like Azure Application Insights can help monitor memory usage and performance.
    • The Premium plan offers various instance sizes. The P3V3 plan should provide enough memory, but if you're frequently hitting limits, ensure you're using the maximum available memory for your instance and adjust your allocation if needed.
    • If issues persist, consider upgrading to a larger instance size. The Premium plan has various SKUs with different memory capacities, and a higher SKU may better support your workload.
    • Ensure your function app settings allow for higher memory usage. For instance, set the Bitness Platform to 64 Bit if you're on a plan with over 4 GB of memory.
    • If your function handles large files, consider splitting the workload into smaller chunks or using asynchronous processing to lower peak memory usage.
    • If your function uses external libraries or services, verify they aren't causing memory bloat, as third-party libraries can sometimes introduce inefficiencies.
    • For your second question about selecting memory above 1.8GB, check the instance memory size options in your Premium plan. The P3V3 plan should support higher memory configurations, so ensure you choose the correct settings in the Azure portal.

    For further clarification, please refer to the following documentations:

    Azure Functions Premium plan

    Troubleshoot Python errors in Azure Functions (python-mode-configuration)

    I hope the above provided information will helps in better understanding and solve your issue, if you have any further concerns, please feel free to reach out to us.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.