简体   繁体   中英

heroku out of memory issue r14

im running a python code on heroku with java and jvm and for some reason java and jvm seems to take all of the memory. Ive tried lowering the max it can use in config vals with java options, but it doesnt seem to work. Heres the logs

2021-11-25T19:08:05.685313+00:00 heroku[worker.1]: source=worker.1 dyno=heroku.237353453.e3a2ee9c-6853-478f-98d7-eb7057461bf8 sample#memory_total=459.22MB sample#memory_rss=447.67MB sample#memory_cache=11.55MB sample#memory_swap=0.00MB sample#memory_pgpgin=291821pages sample#memory_pgpgout=233536pages sample#memory_quota=512.00MB
2021-11-25T19:08:26.682574+00:00 heroku[worker.1]: source=worker.1 dyno=heroku.237353453.e3a2ee9c-6853-478f-98d7-eb7057461bf8 sample#load_avg_1m=0.07 sample#load_avg_5m=0.08 sample#load_avg_15m=0.08
2021-11-25T19:08:26.728173+00:00 heroku[worker.1]: source=worker.1 dyno=heroku.237353453.e3a2ee9c-6853-478f-98d7-eb7057461bf8 sample#memory_total=459.22MB sample#memory_rss=447.67MB sample#memory_cache=11.55MB sample#memory_swap=0.00MB sample#memory_pgpgin=291821pages sample#memory_pgpgout=233536pages sample#memory_quota=512.00M

Are there any solutions to lower the memory usage without making any major changes. also sorry if i didnt give a lot of information about the issue. Im in the middle of something.

edit Just realized i didnt put all of the error logs in here

When dealing with memory footprint in Java applications you need to consider the following:

  • metaspace: it stores the class definitions and metadata
  • heap: it stores the Java objects allocated and used by the application

Reduce metaspace memory
This could be the first step: remove from pom.xml the dependencies that are not necessary (if any). When this is possible the memory can be reduced without major code refactoring.

Consider refactoring existing code to remove large dependencies: this might require some rework/re-test but it can really help.

Analyse also transitive dependencies (imported by dependencies defined in the pom.xml ) and exclude what is not necessary

Reduce heap memory

The next step is to understand (profile) the memory usage of your application to identify where memory allocation can be reduced.

It is easier to perform this on your local dev environment (Java IDEs have a built-in profiler or you can use JVM tools like VisualV), however it is possible to do it on on Heroku .

Find here a good resource about Java memory and Medium post about Java on Heroku

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM