8

只是坐着没有请求,我的内存不断增加,最终超出了内存配额。有很多事情我不明白。

  1. 为什么没有请求时内存使用量不断增加?
  2. “Process running mem”的值来自哪里(我可以说这似乎不是堆和非堆使用中的任何数字组合的总和)。
  3. 为什么即使我有推荐它也会超过JAVA_OPTS: -Xmx384m -Xss512k -XX:+UseCompressedOops -javaagent:heroku-javaagent-1.2.jar=stdout=true

这是日志文件的示例

app/web.1:  heroku-javaagent: JVM Memory Usage     (Heap): used: 275M committed: 349M max:349M 
app/web.1:  heroku-javaagent: JVM Memory Usage (Non-Heap): used: 37M committed: 37M max:219M 
app/web.1:  heroku-javaagent: JVM Threads                : total: 37 daemon: 7 non-daemon: 21 internal: 9 
app/web.1:  heroku-javaagent: JVM Memory Usage     (Heap): used: 276M committed: 349M max:349M 
app/web.1:  heroku-javaagent: JVM Memory Usage (Non-Heap): used: 37M committed: 37M max:219M 
app/web.1:  heroku-javaagent: JVM Threads                : total: 37 daemon: 7 non-daemon: 21 internal: 9 
app/web.1:  heroku-javaagent: JVM Memory Usage     (Heap): used: 277M committed: 349M max:349M 
app/web.1:  heroku-javaagent: JVM Memory Usage (Non-Heap): used: 37M committed: 37M max:219M 
app/web.1:  heroku-javaagent: JVM Threads                : total: 37 daemon: 7 non-daemon: 21 internal: 9 
app/web.1:  heroku-javaagent: JVM Memory Usage     (Heap): used: 277M committed: 349M max:349M 
app/web.1:  heroku-javaagent: JVM Memory Usage (Non-Heap): used: 37M committed: 37M max:219M 
app/web.1:  heroku-javaagent: JVM Threads                : total: 37 daemon: 7 non-daemon: 21 internal: 9 
app/web.1:  heroku-javaagent: JVM Memory Usage     (Heap): used: 278M committed: 349M max:349M 
app/web.1:  heroku-javaagent: JVM Memory Usage (Non-Heap): used: 37M committed: 37M max:219M 
app/web.1:  heroku-javaagent: JVM Threads                : total: 37 daemon: 7 non-daemon: 21 internal: 9 
heroku/web.1:  Process running mem=517M(101.1%) 
heroku/web.1:  Error R14 (Memory quota exceeded) 
heroku/web.1:  Process running mem=517M(101.1%) 
heroku/web.1:  Error R14 (Memory quota exceeded) 
heroku/web.1:  Process running mem=517M(101.1%) 
heroku/web.1:  Error R14 (Memory quota exceeded) 
app/web.1:  heroku-javaagent: JVM Memory Usage     (Heap): used: 212M committed: 349M max:349M 
app/web.1:  heroku-javaagent: JVM Memory Usage (Non-Heap): used: 37M committed: 37M max:219M 
app/web.1:  heroku-javaagent: JVM Threads                : total: 37 daemon: 7 non-daemon: 21 internal: 9 
heroku/web.1:  Process running mem=517M(101.1%) 
heroku/web.1:  Error R14 (Memory quota exceeded) 
heroku/web.1:  Process running mem=517M(101.1%) 
heroku/web.1:  Error R14 (Memory quota exceeded) 
heroku/web.1:  Process running mem=517M(101.1%) 
heroku/web.1:  Error R14 (Memory quota exceeded) 
app/web.1:  heroku-javaagent: JVM Memory Usage     (Heap): used: 213M committed: 349M max:349M 
app/web.1:  heroku-javaagent: JVM Memory Usage (Non-Heap): used: 37M committed: 37M max:219M 
app/web.1:  heroku-javaagent: JVM Threads                : total: 37 daemon: 7 non-daemon: 21 internal: 9 
heroku/web.1:  Process running mem=517M(101.1%) 
heroku/web.1:  Error R14 (Memory quota exceeded) 
heroku/web.1:  Process running mem=517M(101.1%) 
heroku/web.1:  Error R14 (Memory quota exceeded) 
heroku/web.1:  Process running mem=517M(101.1%) 
heroku/web.1:  Error R14 (Memory quota exceeded) 
app/web.1:  heroku-javaagent: JVM Memory Usage     (Heap): used: 213M committed: 349M max:349M 
app/web.1:  heroku-javaagent: JVM Memory Usage (Non-Heap): used: 37M committed: 37M max:219M 
app/web.1:  heroku-javaagent: JVM Threads                : total: 37 daemon: 7 non-daemon: 21 internal: 9 
heroku/web.1:  Process running mem=517M(101.1%) 
heroku/web.1:  Error R14 (Memory quota exceeded) 
heroku/web.1:  Process running mem=517M(101.1%) 
heroku/web.1:  Error R14 (Memory quota exceeded) 
heroku/web.1:  Process running mem=517M(101.1%) 
heroku/web.1:  Error R14 (Memory quota exceeded) 
app/web.1:  heroku-javaagent: JVM Memory Usage     (Heap): used: 214M committed: 349M max:349M 
app/web.1:  heroku-javaagent: JVM Memory Usage (Non-Heap): used: 37M committed: 37M max:219M 
app/web.1:  heroku-javaagent: JVM Threads                : total: 37 daemon: 7 non-daemon: 21 internal: 9 
heroku/web.1:  Process running mem=517M(101.1%) 
heroku/web.1:  Error R14 (Memory quota exceeded) 
heroku/web.1:  Process running mem=517M(101.1%) 
heroku/web.1:  Error R14 (Memory quota exceeded) 
heroku/web.1:  Process running mem=517M(101.1%) 
heroku/web.1:  Error R14 (Memory quota exceeded) 
4

4 回答 4

5

这个问题不应该是 Heroku 特有的,并且应该(理想情况下)能够在本地复制。首先,我建议以 Heroku 运行它的方式在本地运行您的应用程序:

然后我会使用一个内存分析器,比如VisualVM来附加到你在本地运行的应用程序,看看发生了什么。

如果这不起作用,或者您想更好地了解 Heroku 上的内存使用情况,我建议启用log-runtime-metrics。这也可以与Log2Viz一起使用以获得实时的内存可视化。

于 2013-04-09T17:38:21.380 回答
2

刚遇到类似的问题。我无法在本地重现该问题。事实证明,我们的日志记录配置中有一个文件附加程序。写入日志会使内存增长。您可以通过编写一个记录大量日志的小应用程序来验证这一点。如果启用 log-runtime-metrics,您将看到 memory_cache 和 memory_total 增长。

于 2014-09-17T10:41:40.147 回答
0

在 heroku 中启用 log-runtime-metrics:

$ heroku labs:enable log-runtime-metrics
Enabling log-runtime-metrics for myapp... done
$ heroku restart

这将允许您在日志中查看内存使用情况

heroku logs -t

https://devcenter.heroku.com/articles/log-runtime-metrics

于 2013-11-07T16:56:28.507 回答
0

我在 grails 应用程序中有相同的错误消息,我阅读了这篇文章,解决方案很简单,在根文件夹中创建一个system.property文件,内容为java.runtime.version=1.7,然后我重新部署应用程序,错误 R14 消失了

我希望它有帮助

于 2014-06-03T15:32:29.820 回答