我目前正在尝试在Go代码中调试令人讨厌的内存泄漏.
我知道的:
pprof带-base标志)runtime.NumGoroutine())object = nil,内存将被垃圾收集(好!但现在我与其他使用此对象的go-routines进行数据竞争)我不知道的是:
感谢您的时间和建议!
我有一个工作流程,可以执行一堆模糊测试,最后计算所有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)
有人知道我做错了什么吗?谢谢你!
假设我们有以下表格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
所以我需要拿出别的东西,我正在寻求你的帮助!
我有两个顶级数组,它们具有相同的格式。我想将它们合并:
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"}]"
有人可以帮我吗?提前致谢。
我想将一些参数传递给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)
这是主管: …
debugging ×1
erlang ×1
erlang-otp ×1
github ×1
go ×1
jbuilder ×1
json ×1
memory-leaks ×1
postgresql ×1
ruby ×1
sql ×1