Basic spring app run out of memory

Hi, I start up basic dockerized Spring app with some simple endpoints (geting data from db).
I have Hobby plan - 256MB available memory.

App runs out of memory

2022-10-24T16:45:29.966 app[19af8536] fra [info] [ 871.168202] Out of memory: Killed process 520 (java) total-vm:2226896kB, anon-rss:200996kB, file-rss:0kB, shmem-rss:0kB, UID:0 pgtables:732kB oom_score_adj:0

But why? Localy I started same app at docker with 128MB memory and it work without any problems.
Whats going on?

Hey there,

With such a small amount of memory, an app can consume it all very quickly. It usually won’t show in metrics and so investigating a process’s memory usage is a tremendous amount of work. You’d need to run it in a way that simulates what’s happening in production, use a profiler, etc.

The simplest thing to do is add more memory and see if the problem continues. Increasing a 256MB app to 1GB of memory costs less than $4/mo. We designed this to be easy because adding memory is a useful debugging step. There’s an easy way to add more memory with the fly scale memory command. More info on this here- Scaling and Autoscaling · Fly Docs

There is also an article that could possibly be helpful to you if you so choose to check it out- Heroku is dead: Let's deploy Spring Boot containers on!. There is a section in there towards the bottom that talks about reducing your application’s memory footprint.