简体   繁体   English

heroku 出 memory 问题 r14

[英]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. 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.我尝试使用 java 选项降低它可以在配置值中使用的最大值,但它似乎不起作用。 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.是否有任何解决方案可以在不进行任何重大更改的情况下降低 memory 的使用率。 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:在 Java 应用程序中处理 memory 占用空间时,您需要考虑以下几点:

  • metaspace: it stores the class definitions and metadata元空间:它存储 class 定义和元数据
  • heap: it stores the Java objects allocated and used by the application堆:它存储应用程序分配和使用的 Java 对象

Reduce metaspace memory减少元空间 memory
This could be the first step: remove from pom.xml the dependencies that are not necessary (if any).这可能是第一步:从pom.xml中删除不必要的依赖项(如果有的话)。 When this is possible the memory can be reduced without major code refactoring.如果可能,memory 可以在不进行主要代码重构的情况下减少。

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还分析传递依赖项(由pom.xml中定义的依赖项导入)并排除不必要的

Reduce heap memory减少堆 memory

The next step is to understand (profile) the memory usage of your application to identify where memory allocation can be reduced.下一步是了解(分析)您的应用程序的 memory 用法,以确定可以减少 memory 分配的位置。

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 .在本地开发环境中执行此操作更容易(Java IDE 具有内置分析器,或者您可以使用 JVM 工具,如 VisualV),但是可以在 Heroku上执行此操作。

Find here a good resource about Java memory and Medium post about Java on Heroku在这里找到一个关于 Java memory 的好资源和关于 Java 在 Z1A794179361C9AD39E88FZ8 上的中等帖子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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