加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 当在本地使用Rails 4时使用rbtrace时,如何防止

发布时间:2020-12-17 02:24:18 所属栏目:百科 来源:网络整理
导读:所以我在本地运行Rails 4应用程序(API),进程ID为11697.我有以下设置,但是我通过bash命令得到以下响应: *** run `sudo sysctl kernel.msgmnb=1048576` to prevent losing events (currently: 16384 bytes)*** attached to process 11697*** timed out waitin
所以我在本地运行Rails 4应用程序(API),进程ID为11697.我有以下设置,但是我通过bash命令得到以下响应:

*** run `sudo sysctl kernel.msgmnb=1048576` to prevent losing events (currently: 16384 bytes)
*** attached to process 11697
*** timed out waiting for eval response
*** detached from process 11697

在超时之前似乎没有等待600秒. I’ve seen this PR on github,so it seems like it should work.

这里的目标是获取Rails应用程序对象的多个堆快照,并比较2个差异以尝试检测内存泄漏.

到config / environment.rb

# Load the Rails application.
require File.expand_path('../application',__FILE__)
require 'rbtrace'

# Initialize the Rails application.
Rails.application.initialize!

bash命令提示符

bundle exec rbtrace -p 11697 -e 'Thread.new{require "objspace"; ObjectSpace.trace_object_allocations_start; GC.start(); ObjectSpace.dump_all(output: File.open("heap.json","w"))}.join'  --timeout=600

解决方法

看起来像是一个不同的PR(42)是6月14日 actually merged解决这个问题的那个,并且他们自 February 13th以来没有发布过rbtrace

所以代码被合并到master中,但它还没有通过rubygems.org发布.

您可以在gemfile中添加rbtrace gem的主分支作为依赖项,如下例所示.您将拥有为eval启用超时选项的PR代码,但主分支可能尚未完全准备好用于生产.使用风险自负!

gem 'rbtrace',git: 'https://github.com/tmm1/rbtrace',branch: 'master'

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读