Increase Firebase function memory step-by-step. Learn to install Firebase tools, update your code with runWith memory config, deploy, and verify your function.

Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
Step 1: Install or Update Firebase Tools
Ensure you have Firebase CLI installed. If it’s not installed, or if you need to update it:
npm install -g firebase-tools
Verify the installation:
firebase --version
Step 2: Initialize Firebase in Your Project
Navigate to your project directory and set up Firebase if it's not already initialized:
firebase init functions
Step 3: Open the Firebase Functions Directory
Navigate to the functions directory of your project:
cd functions
Step 4: Open and Edit index.js (or main function file)
Locate the index.js or the main file where your Firebase functions are defined. Open this file using your preferred code editor.
Step 5: Specify Memory Allocation
In the function definition, you can specify the amount of memory you want to allocate. Use the runWith method to do this. For example, to allocate 2 GB of memory:
const functions = require('firebase-functions');
exports.myFunction = functions.runWith({
memory: '2GB'
}).https.onRequest((request, response) => {
response.send("Hello from Firebase!");
});
The available memory options are 128MB, 256MB, 512MB, 1GB, 2GB, 4GB, and 8GB.
Step 6: Deploy the Updated Function
Ensure you are in your functions directory and deploy your function:
firebase deploy --only functions
Step 7: Verify the Deployment
After deployment, you can verify the allocated memory via the Firebase Console. Navigate to Functions, select your function, and verify the memory setting.
Step 8: Testing
Once deployed, test your function ensuring that it performs as expected with the updated memory allocation.
Additional Notes
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.