小编mel*_*kes的帖子

有没有办法知道谁在Go中拥有对象的引用?

我目前正在尝试在Go代码中调试令人讨厌的内存泄漏.

我知道的:

  • 内存在哪里(pprof-base标志)
  • 为什么要分配新内存(我们的代码中的"重新连接"功能)
  • goroutines的数量没有增长(runtime.NumGoroutine())
  • 如果我这样做object = nil,内存将被垃圾收集(好!但现在我与其他使用此对象的go-routines进行数据竞争)

我不知道的是:

  • 为什么新的内存不被垃圾收集.为此,我需要知道谁持有对象的引用.

感谢您的时间和建议!

debugging memory-leaks go

19
推荐指数
1
解决办法
1208
查看次数

Github Actions:设置输出似乎不起作用

我有一个工作流程,可以执行一堆模糊测试,最后计算所有crashers子目录中的文件总数。后来,在另一项工作中,我使用该号码向 Slack 发送通知。但是,由于某种原因,::set-output不会产生任何输出,最重要的是,即使数量crashers不为零,下一个作业也不会运行!

jobs:
  fuzz-nightly-test:
    runs-on: ubuntu-latest
    steps:
      ...
      - name: Set crashers count
        working-directory: test/fuzz
        run: echo "::set-output name=crashers-count::$(find . -type d -name 'crashers' | xargs -I % sh -c 'ls % | wc -l' | awk '{total += $1} END {print total}')"
        id: set-crashers-count

   outputs:
     crashers-count: ${{ steps.set-crashers-count.outputs.crashers-count }}

  fuzz-nightly-fail:
    needs: fuzz-nightly-test
    if: ${{ needs.set-crashers-count.outputs.crashers-count != 0 }}
    runs-on: ubuntu-latest
    steps:
      ...
Run Code Online (Sandbox Code Playgroud)

有人知道我做错了什么吗?谢谢你!

github github-actions

6
推荐指数
1
解决办法
1万
查看次数

SQL获取具有相同列A但不同B的记录

假设我们有以下表格meals:

| meal  | stars |
-----------------
| steak |   1   |
| steak |   2   |
| fish  |   4   |
| fish  |   4   |
| salad |   5   |

如何获得同一顿饭但不同星星的记录?我需要只有不同星星的记录.

上表的结果应如下:

| meal  | stars |
-----------------
| steak |   1   |
| steak |   2   |

我尝试过以下查询:

SELECT DISTINCT t1.*
FROM meals t1
INNER JOIN meals t2 ON t1.meal = t2.meal
AND t1.stars <> t2.stars;
Run Code Online (Sandbox Code Playgroud)

但它耗费了太多时间和一些明显的内存.

我桌子的实际大小是:

SELECT pg_size_pretty(pg_relation_size('table_name')); 
 pg_size_pretty 
----------------
 2295 MB

所以我需要拿出别的东西,我正在寻求你的帮助!

sql postgresql query-performance

4
推荐指数
1
解决办法
330
查看次数

Jbuilder:如何合并两个顶级数组?

我有两个顶级数组,它们具有相同的格式。我想将它们合并:

json = Jbuilder.encode do |json|
  json.(companies) do |json, c|
    json.value c.to_s
    json.href employee_company_path(c)
  end
  json.(company_people) do |json, cp|
    json.value "#{cp.to_s} (#{cp.company.to_s})"
    json.href employee_company_path(cp.company)
  end
end
Run Code Online (Sandbox Code Playgroud)

因此输出如下: "[{value: "a", href: "/sample1"}, {value: "b", href: "/sample2"}]"

但是上面的代码不起作用。它仅包含第二个数组:"[{value: "b", href: "/sample2"}]"

有人可以帮我吗?提前致谢。

ruby json ruby-on-rails jbuilder ruby-on-rails-3

3
推荐指数
2
解决办法
3817
查看次数

应用程序启动时将一些参数传递给主管 init 函数

我想将一些参数传递给supervisor:init/1函数,并且希望应用程序的界面如下所示:

redis_pool:start() % start all instances
redis_pool:start(Names) % start only given instances
Run Code Online (Sandbox Code Playgroud)

这是应用程序:

-module(redis_pool).
-behaviour(application).

...

start() -> % start without params
    application:ensure_started(?APP_NAME, transient).

start(Names) -> % start with some params
    % I want to pass Names to supervisor init function
    % in order to do that I have to bypass application:ensure_started
    % which is not GOOD :(
    application:load(?APP_NAME),
    case start(normal, [Names]) of
        {ok, _Pid} -> ok;
        {error, {already_started, _Pid}} -> ok
    end.

start(_StartType, StartArgs) ->
    redis_pool_sup:start_link(StartArgs).
Run Code Online (Sandbox Code Playgroud)

这是主管: …

erlang erlang-otp

2
推荐指数
1
解决办法
949
查看次数