Spring boot high memory usage after some time

Viewed 4109

I have a spring boot app deployed on digital ocean, my current droplet (virtual pc, named as droplet) has 1gb of memory.

My app has some cron jobs that get infos from some APIs and stores on the db, i will explain it:

@Scheduled(cron = "50 0 0/12 * * ?")

^ this one clean some values from a table

@Scheduled(cron = "50 0 0/1 * * ?")

^ Same as above but for another table

@Scheduled(cron = "0 0/1 * * * ?")

^ Have two of this, that get infos from a API, do some math accounts and then store the results on db.

What i see from the monitoring tools is that my memory usage never goes down it always goes up a litle bit.

It start with 40% of usage about 5 hours ago and now its at 75%.

Theres something that i can do to cleanup the memory usage? Maybe a garbage collection?

Im using mysql, btw

Thanks

-- Edit

I just run visualvm, and the results are the show:

Profiler: Profiler

Monitor: Monitor

Seems like gc is actually running, so, whats wrong? maybe i need to set max heap at digital ocean?

4 Answers

In real word applications resources are valuable for developers and companies to spend some money to increase resources.So, every modern application need background works with minimum memory usage.@Schedule is an expensive annotation for JVM.Instead of using this annotation i recommend to you to use TaskQueues such as Celery and Redis.You can Requeue tasks in Redis and then redis publishes them.It is very useful for big processes and background processes.

Related