- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我一直在使用 Dave Cheney's gcvis
tool以解决内存泄漏问题。一切顺利,问题解决。
但是,我不知道该怎么做,但我这辈子都无法阻止垃圾收集器输出淹没我的日志,这让开发变得非常困难。
根据 the runtime
-package manual :
Setting gctrace to any value > 0 also causes the garbage collector to emit a summary when memory is released back to the system.
然而,这没有任何效果。
如何删除输出?
我尝试了以下方法:
导出为空值
$ export GODEBUG=
$ go run main.go
取消设置
$ unset GODEBUG
$ go run main.go
设置为零 (也尝试过不带引号,只是为了完成)
$ export GODEBUG="gctrace=0"
$ go run main.go
无论如何,我每次都会得到这个输出(包名称已编辑):
# my-package-0
gc 1 @0.006s 10%: 0.025+3.4+0.11 ms clock, 0.20+1.7/5.9/1.7+0.94 ms cpu, 4->4->3 MB, 5 MB goal, 8 P
gc 2 @0.019s 7%: 0.005+1.0+0.086 ms clock, 0.047+0.67/1.8/2.8+0.69 ms cpu, 5->5->4 MB, 6 MB goal, 8 P
gc 3 @0.030s 6%: 0.006+2.8+0.091 ms clock, 0.053+0.10/4.8/4.2+0.73 ms cpu, 7->8->6 MB, 8 MB goal, 8 P
gc 4 @0.050s 6%: 0.030+4.2+0.096 ms clock, 0.24+1.0/7.3/3.7+0.76 ms cpu, 13->14->8 MB, 14 MB goal, 8 P
# my-package-1
gc 1 @0.007s 5%: 0.010+2.6+0.15 ms clock, 0.086+0.19/3.4/2.6+1.2 ms cpu, 4->4->2 MB, 5 MB goal, 8 P
gc 2 @0.015s 6%: 0.007+2.5+0.11 ms clock, 0.060+0.63/3.4/2.4+0.91 ms cpu, 5->5->4 MB, 6 MB goal, 8 P
gc 3 @0.028s 6%: 0.010+3.0+0.53 ms clock, 0.084+0.23/2.7/2.4+4.2 ms cpu, 8->9->5 MB, 9 MB goal, 8 P
# my-package-3
gc 1 @0.009s 15%: 0.012+4.5+1.7 ms clock, 0.10+0.62/4.5/0.77+13 ms cpu, 4->4->2 MB, 5 MB goal, 8 P
gc 2 @0.030s 9%: 0.006+2.8+0.10 ms clock, 0.050+0.63/3.7/2.9+0.85 ms cpu, 5->5->4 MB, 6 MB goal, 8 P
gc 3 @0.043s 11%: 0.53+3.9+0.084 ms clock, 4.3+7.0/7.8/5.2+0.67 ms cpu, 9->10->7 MB, 10 MB goal, 8 P
gc 4 @0.062s 10%: 0.027+3.6+0.12 ms clock, 0.21+5.2/6.3/5.0+1.0 ms cpu, 12->13->8 MB, 14 MB goal, 8 P
# my-package-4
[...]
根据评论中的要求,这是 $ go env
的输出:
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/dimholt/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/dimholt/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/fx/p9gpbcnd5_jdgqyp6z1w9tqr0000gn/T/go-build333219542=/tmp/go-build -gno-record-gcc-switches -fno-common"
还有我的main.go
:
package main
import (
"fmt"
"log"
"net/http"
"github.com/redacted/config"
"github.com/redacted/db"
)
func main() {
conf := config.GetConfig()
// Connect database.
db.Connect()
defer db.Close()
// Register all HTTP routes.
registerRoutes()
port := fmt.Sprintf(":%v", conf.Port)
log.Printf("documents: listening on port %v", port[1:])
log.Fatal(http.ListenAndServe(port, nil))
}
最佳答案
万一其他人遇到这个问题,这对我有用。
go clean -cache
关于go - 如何取消设置 $GODEBUG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55955610/
是否可以使用标准输入/标准输出在 bash 中压缩/解压缩字符串? 我试过了,但显然不支持它? hey=$(echo "hello world" | gzip -cf) echo $hey # ret
我的任务是让一个企业网站适用于 IE7,它必须“足够好”,因此我禁用了任何导致问题的花哨/非必要功能。 其中之一是正在使用的搜索栏,需要进行哪些搜索,我猜测幕后某个地方有某种 JavaScript 用
我有一个执行大量处理的小程序。您可以通过按回车键打印进度。 我实现它的方法是在主线程中完成处理,同时我有一个 pthread 不断循环 getchar() 以等待输入键。 问题是当我完成处理时。发生这
我完全理解 suspendCoroutine 与 suspendCancellableCoroutine 在我的示例中的工作方式。但我想知道为什么 println("I finished") (第 1
我是 QT 的新手。目前在我的项目中我实现了 QFileDialog . 在我的用例中:每当用户选择一个文本文件时,它都会执行 functionA .但是,我发现如果在文件对话框中单击取消,funct
我有代码,仅在用户选择“另存为”时运行。为此并获取我正在使用的文件的新名称 Application.GetSaveAsFilename功能。 我遇到的问题是类型不匹配,同时检查用户是否在他没有这样做时
我的 UILocalNotification 有问题。 我正在用我的方法安排通知。 - (void) sendNewNoteLocalReminder:(NSDate *)date alrt:(NS
祝你有美好的一天 我有一个网站,其中有很多“工具提示”。这些工具提示是在将鼠标悬停在文本的特定部分上时创建的。工具提示是一个 div block ,它显示在网站上所有其他内容的顶部,并且当光标从文本移
我遇到以下问题。每隔 2 秒,程序就会进入 if 语句。在这个 if 语句中,我想要一个计时器,它会在 15 秒后给我一条消息。计时器应延迟 1 秒运行。但是当我用计时器“等待”时,if 语句将再执行
基本上我有以下代码片段, (let [task (FutureTask. fn) thr (Thread. task)] (.start thr) ;;wait for signa
取消正在进行的 ASIHttpRequest 请求的正确位置在哪里?这就是我取消的方式,但是当我 时它继续崩溃在不让请求完成的情况下从一个 View Controller 转移到另一个 View Co
我在我的 winforms 应用程序中使用 BackgroundWorker 来执行另一个类中发生的长时间运行的任务(执行数据库操作)。由于所有工作都是在另一个类中完成的,因此取消并不那么简单。我在另
我正在使用 OneSignal 向我的用户显示通知。通知工作正常,但我注意到,如果我在通知栏中“滑动”取消通知,则通知将永远保留,这是一张显示应用程序图标上的通知的图像,我想在应用程序已打开: 我看到
正在运行的 AsyncTask 的 .cancel(boolean) 方法如何工作?这是文档: Attempts to cancel execution of this task. This atte
我注意到,当我激活约束时,我会立即在该行代码处收到一条警告,指出不能同时满足约束。 我假设布局是在“UI 更新周期”之类的稍后时间点计算的,而不是每次约束都被(取消)激活。因此,在(取消)激活约束的代
这是我创建线程的方式: readFromWebThread = [[NSThread alloc] initWithTarget:self selector:@selector(loadThread:
我目前正在尝试取消与我的数据模型中的对象关联的特定 UILocalNotifications。为此,每个数据对象都有一个唯一标识符,即 NSUUID。 创建 UILocalNotification:
当我提交并单击“确定”时,它会继续,但当我按“取消”时,它仍然会提交。我尝试使用此代码,但提交和取消按钮仍然执行相同的操作。 model.saveForm = function() { var
我有一个警报弹出窗口,当发生特定操作时会出现该弹出窗口。 5 秒后,使用 setTimeout() 隐藏警报弹出窗口。 我遇到的问题是,如果我多次触发弹出窗口,有时后续的弹出窗口会出现但立即消失。我相
我有一些 javascipt (jQuery),其中单击按钮时会淡入 #myDiv,然后使用超时函数在 5 秒后再次淡出。它工作正常,但如果用户在超时内的 fadeOut 函数运行之前再次单击该按钮,
我是一名优秀的程序员,十分优秀!