Should I add memory?

Hi, everyone.

I am developing a Web app with the following technology stack.

  • Frontend
    • React 18.2.0
    • Next.js 13.2.4
  • Backend
    • Rails 7.0.4 API Mode
      • ActiveStorage
  • Storage
    • Amazon S3
    • PostgreSQL

My app has the ability to import and upload external files.
When I try to save an image file converted from HEIC to JPEG, I get the following error.

The size of the file you are attempting to appraise is about 0.5MB to 1.5MB.

By the way, it works fine in my local environment.

Console logs:

Access to XMLHttpRequest at '' from origin '' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

POST net::ERR_FAILED 502 logs:

2023-06-16T13:17:08.347 app[24d891222f1487] nrt [info] ERROR No such file or directory (os error 2)

2023-06-16T13:17:08.352 app[24d891222f1487] nrt [info] I, [2023-06-16T13:17:08.352032 #513] INFO -- : [5b6716b7-eb2e-4c77-8bd4-41fa98a1ec29] Started GET "/api/v1/users/find?" for 2a09:8280:1::69:2b9c at 2023-06-16 13:17:08 +0000

2023-06-16T13:17:08.353 app[24d891222f1487] nrt [info] I, [2023-06-16T13:17:08.353418 #513] INFO -- : [5b6716b7-eb2e-4c77-8bd4-41fa98a1ec29] Processing by Api::V1::UsersController#find_user as HTML

2023-06-16T13:17:08.353 app[24d891222f1487] nrt [info] I, [2023-06-16T13:17:08.353482 #513] INFO -- : [5b6716b7-eb2e-4c77-8bd4-41fa98a1ec29] Parameters: {"email"=>""}

2023-06-16T13:17:08.412 app[24d891222f1487] nrt [info] I, [2023-06-16T13:17:08.412420 #513] INFO -- : [5b6716b7-eb2e-4c77-8bd4-41fa98a1ec29] Completed 200 OK in 59ms (Views: 0.6ms | ActiveRecord: 30.3ms | Allocations: 9702)

2023-06-16T13:17:08.536 app[06e82d339f5387] nrt [info] I, [2023-06-16T13:17:08.535692 #513] INFO -- : [20af311a-1374-4a9f-acea-4412a65e3d90] Started POST "/api/v1/photos" for 2a09:8280:1::69:2b9c at 2023-06-16 13:17:08 +0000

2023-06-16T13:17:08.540 app[06e82d339f5387] nrt [info] I, [2023-06-16T13:17:08.539728 #513] INFO -- : [20af311a-1374-4a9f-acea-4412a65e3d90] Processing by Api::V1::PhotosController#create as HTML

2023-06-16T13:17:08.540 app[06e82d339f5387] nrt [info] I, [2023-06-16T13:17:08.539871 #513] INFO -- : [20af311a-1374-4a9f-acea-4412a65e3d90] Parameters: {"image"=>#<ActionDispatch::Http::UploadedFile:0x00007ff8f5eedef0 @tempfile=#<Tempfile:/tmp/RackMultipart20230616-513-b5h9lw>, @original_filename="blob", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"image\"; filename=\"blob\"\r\nContent-Type: image/jpeg\r\n">, "croppedImage"=>#<ActionDispatch::Http::UploadedFile:0x00007ff8f5eedea0 @tempfile=#<Tempfile:/tmp/RackMultipart20230616-513-fapr6j.jpeg>, @original_filename="croppedImage.jpeg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"croppedImage\"; filename=\"croppedImage.jpeg\"\r\nContent-Type: image/jpeg\r\n">, "latitudeData"=>"foobar", "longitudeData"=>"foobar", "addressData"=>"foobar", "currentUserId"=>"1", "currentSutraId"=>"25"}

2023-06-16T13:17:08.852 app[06e82d339f5387] nrt [info] [ 72.402414] Out of memory: Killed process 513 (ruby) total-vm:982076kB, anon-rss:187304kB, file-rss:0kB, shmem-rss:0kB, UID:1000 pgtables:804kB oom_score_adj:0

2023-06-16T13:17:08.863 proxy[06e82d339f5387] nrt [error] could not make HTTP request to instance: connection closed before message completed

2023-06-16T13:17:09.673 app[06e82d339f5387] nrt [info] INFO Main child exited with signal (with signal 'SIGKILL', core dumped? false)

2023-06-16T13:17:09.673 app[06e82d339f5387] nrt [info] INFO Starting clean up.

2023-06-16T13:17:09.674 app[06e82d339f5387] nrt [info] WARN hallpass exited, pid: 514, status: signal: 15 (SIGTERM)

2023-06-16T13:17:09.674 app[06e82d339f5387] nrt [info] INFO Process appears to have been OOM killed!

2023-06-16T13:17:09.680 app[06e82d339f5387] nrt [info] 2023/06/16 13:17:09 listening on [fdaa:1:d5f8:a7b:17c:66aa:fefb:2]:22 (DNS: [fdaa::3]:53)

2023-06-16T13:17:10.672 app[06e82d339f5387] nrt [info] [ 74.223291] reboot: Restarting system

2023-06-16T13:17:10.818 app[06e82d339f5387] nrt [info] Out of memory: Killed process

2023-06-16T13:17:10.830 runner[06e82d339f5387] nrt [info] machine did not have a restart policy, defaulting to restart

2023-06-16T13:17:11.221 app[06e82d339f5387] nrt [info] INFO Starting init (commit: 0b28cec)...

2023-06-16T13:17:11.239 app[06e82d339f5387] nrt [info] INFO starting statics vsock server

2023-06-16T13:17:11.240 app[06e82d339f5387] nrt [info] INFO Preparing to run: `/rails/bin/docker-entrypoint ./bin/rails server` as rails

2023-06-16T13:17:11.245 app[06e82d339f5387] nrt [info] INFO [fly api proxy] listening at /.fly/api

2023-06-16T13:17:11.254 app[06e82d339f5387] nrt [info] 2023/06/16 13:17:11 listening on [fdaa:1:d5f8:a7b:17c:66aa:fefb:2]:22 (DNS: [fdaa::3]:53)

2023-06-16T13:17:13.042 app[06e82d339f5387] nrt [info] => Booting Puma

2023-06-16T13:17:13.042 app[06e82d339f5387] nrt [info] => Rails application starting in production

2023-06-16T13:17:13.042 app[06e82d339f5387] nrt [info] => Run `bin/rails server --help` for more startup options

2023-06-16T13:17:13.794 app[06e82d339f5387] nrt [info] Puma starting in single mode...

2023-06-16T13:17:13.794 app[06e82d339f5387] nrt [info] * Puma version: 5.6.5 (ruby 3.2.1-p31) ("Birdie's Version")

2023-06-16T13:17:13.794 app[06e82d339f5387] nrt [info] * Min threads: 5

2023-06-16T13:17:13.794 app[06e82d339f5387] nrt [info] * Max threads: 5

2023-06-16T13:17:13.794 app[06e82d339f5387] nrt [info] * Environment: production

2023-06-16T13:17:13.794 app[06e82d339f5387] nrt [info] * PID: 513

2023-06-16T13:17:13.794 app[06e82d339f5387] nrt [info] * Listening on

2023-06-16T13:17:13.797 app[06e82d339f5387] nrt [info] Use Ctrl-C to stop

Machines represent your running app VMs

Out of memory: Killed process 513, so I think it is a memory capacity issue, but is it impossible to do what I want to do with the memory specs of’s free quota?

One common pattern is to add some swap space and set some swapiness (must run those commands as root, though): Can't install nimble_parsec - #3 by jerome

1 Like

See also Dockerfiles and fly.toml · Fly Docs


Thank you for reply.

How much RAM do I need to add ?

The amount of memory you need varies depending on lots of different factors. For Rails apps, I’d start at 512Mb minimum and go up from there if you need more.

1 Like

Thank you for reply.
I increased the size to 512 MB.
I have just increased the size and confirmed the operation. I was able to save image file safely.

Thank you very much :blush:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.