Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Cloud run in-memory volume limit reached but no error was thrown

 

Hello, I've google cloud run service and I added in-memory volume, As test I made it size: `

49152 bytes`, And I'm writing file of size `28kb`, each operation will create the file & then read it to base64
 

 

const base64Data = await fs.readFile(fileName, 'base64')
console.log('base64 length ', typeof base64Data, ' , ', base64Data?.length)

 

 
The first 2 documents are created and read without issue ( as those should be around 90% of the volume size ) writing any other file should throw error but it doesn't, file is created but it seems to have 0 size, the above command will give me this result for any document after 2nd one `base64 length string , 0`
 
I created 5 more files after and they all created but without size ( no error of limit was thrown ), Runing this command to get files in the memory show all 7 files

 

const files = await fs.readdir('/mnt/memoryStorage-volume')
console.log('\nCurrent directory filenames:', files.length)
files.forEach(file => {
console.log(file)
})

 

 
0 2 301
2 REPLIES 2

Hi @IbrahimSluma,

When the in-memory volume hits its max size, further write operations will fail, usually causing an "out of memory" error. However, this doesn't automatically stop your container instance. Your app can catch and handle this error, allowing the container to keep running even though it's unable to write more data.

To troubleshoot, you can check your Cloud Logs for any "out of memory" errors. If you see messages indicating that your container instance is running out of memory, you can follow the suggested actions to resolve it, like increasing the memory allocation for your Cloud Run instance.

Just a heads-up: if your app itself throws memory-related errors (like java.lang.OutOfMemoryError), this won't necessarily crash the container. As long as your overall memory usage doesn’t exceed the container's memory limit, the instance will keep running. However, this can still affect request handling, as the app might hang or time out if it's waiting for more memory but can't get it.

Hope this helps.

@mcbsalceda 

Nope, creating file didn't throw any error the file was created and I confirmed it was created because I run `

fs.readdir

 and I can see the new file exist but it has no size at all ! ( no data )

Maybe there was small space left so file was created but without data ? but that's bug too because if file failed to write it should thrown error !