R
Railwayβ€’15mo ago
Adrian Bienias

Constantly growing RAM usage

I have the app that works as an autoresponder. It checks the database every minute to compare if messages should be sent to users, depending on the time passed from their signup date. Number of autoresponder messages and number of users is constant from the last 7 days, but the usage of RAM is constantly growing. The down peak occurred when I restarted the app. The restart freed the RAM, but after that point the app again is using more and more RAM. Any ideas how can I flatten the RAM usage?
Solution:
Your app may have a memory leak. Here's how to flatten the RAM usage: 1. Profiling: Use memory profiling tools specific to your language or framework to identify areas of the code that continually allocate memory without releasing it. 2. Database Connections: Ensure that database connections are closed properly after their use. 3. Caching: If you're using caching, ensure items are evicted when no longer needed....
Jump to solution
10 Replies
Percy
Percyβ€’15mo ago
Project ID: 7b20ef7d-243f-4f1c-a7f8-33284b9b8efd
Adrian Bienias
Adrian Bieniasβ€’15mo ago
Project ID: 7b20ef7d-243f-4f1c-a7f8-33284b9b8efd
Brody
Brodyβ€’15mo ago
fix the memory leak and you fix the growing ram usage πŸ™‚
Solution
hrhristov
hrhristovβ€’15mo ago
Your app may have a memory leak. Here's how to flatten the RAM usage: 1. Profiling: Use memory profiling tools specific to your language or framework to identify areas of the code that continually allocate memory without releasing it. 2. Database Connections: Ensure that database connections are closed properly after their use. 3. Caching: If you're using caching, ensure items are evicted when no longer needed. 4. Data Structures: Ensure large data structures or objects are de-referenced after use, allowing garbage collection to reclaim the memory. 5. Garbage Collection: If your language supports manual garbage collection, try triggering it periodically.
Brody
Brodyβ€’15mo ago
if that's an AI answer, it's a good one if it's not, then it's also a good answer
hrhristov
hrhristovβ€’15mo ago
Yes, it is the GPT-4 wisdom πŸ˜€
Brody
Brodyβ€’15mo ago
well I don't mind if it's an AI answer as long as it's a good answer! I'd only have a problem if it was making stuff up or getting stuff wrong
hrhristov
hrhristovβ€’15mo ago
When helping others, I often use AI to reduce typing. However, I always proofread and only approve answers that match my intent. A workaround is to run this as a Cron job, but note that the min time between jobs is 15 mins on Railway
Brody
Brodyβ€’15mo ago
sounds good to me
Adrian Bienias
Adrian Bieniasβ€’15mo ago
@Brody , @hrhristov, thanks for the hints!
Want results from more Discord servers?
Add your server