How does Ruby allocate memory on boot?

I use rails on the Hirk. After restarting my application on heroku, I have a peak of memory of 400-500 MB (about 20 M objects are allocated). It also takes some time before it is ready for use. If I, for example, on the home page and do not use any other controller except the application controller, this is normal. But when I go to some page where another controller is used, the peak occurs, and it is always the same size, it does not matter which page I request.

I tried to measure it somehow, but without success. I use Scout, where I see this memory bloat, but it doesn’t help me much, because it shows that the peak depends on which page I asked first.

It seems that Ruby allocates some memory "just in case", based on my application structure, models, controllers ... (?). Does anyone have something similar? Is this something that is expected?

I have thousands of records in the database, but even if I clean my database, ruby ​​reserves this memory the same way. Ruby ver. 2.4.2, Rails 5.1.4 I use fragment caching, and when the application loads (with 400-500 MB memory), it works fine, not slow.

+5
source share

Source: https://habr.com/ru/post/1274034/


All Articles