tech
Go: runtime.SetFinalizer 详解
本文介绍了Go语言中的runtime.SetFinalizer函数,探讨了如何在对象被垃圾回收之前执行清理操作。通过示例代码,展示了SetFinalizer的用法及其潜在问题,如内存泄漏和对象生命周期延长。文章还提到在实际应用中,SetFinalizer的使用较少,但在Go源码中有广泛应用,提供了对资源管理的深刻见解。
tech
本文介绍了Go语言中的runtime.SetFinalizer函数,探讨了如何在对象被垃圾回收之前执行清理操作。通过示例代码,展示了SetFinalizer的用法及其潜在问题,如内存泄漏和对象生命周期延长。文章还提到在实际应用中,SetFinalizer的使用较少,但在Go源码中有广泛应用,提供了对资源管理的深刻见解。
tech
如何在 Go 中避免内存泄露?关注关闭文件、HTTP 响应体、字符串管理及 goroutine 使用。及时释放资源,避免循环引用,使用 defer 时要小心,助你写出健壮的代码!#GoLang #内存泄露
tech
In the previous article, I implemented a simple RPC interface using the net/rpc package and tried out the Gob encoding that comes with net/rpc and JSON encoding to learn some basics of Golang RPC. In this post, I'll combine net/rpc with protobuf and create my
tech
Exploring the Benefits of Using `tmux`: A Quick Guide to Terminal Multiplexing. tmux is a terminal multiplexer: it enables a number of terminals to be crea。
tech
Mac: tmux 最佳实践. tmux 是一个终端多路复用器:它允许从单个屏幕创建、访问和控制多个终端。 tmux 可能会与屏幕分离并继续在后台运行,然后重新连接。 第一次看到 tmux 的介绍的时候,我其实没什么感觉,觉得没什么.后面用terminal多了,遇到了一些问题,然后尝试解决,最后我重新认真学习。
tech
Go High-Performance Programming EP9: Escape Analysis. From the perspective of the Go compiler, memory allocation happens in two places: the stack and the h。
tech
RPC是远程过程调用的简称,是分布式系统中不同节点间流行的通信方式。是互联网时代的基石技术,Go语言的标准库也提供了一个简单的RPC实现,Go语言的RPC包的路径为net/rpc,本篇文章的目的是利用net/rpc 实现一个简单的RPC 接口,帮助我们拨开RPC 的迷雾。 对 net/rpc 而言,一个函数需要能够被远程调用,需要满足如下五个条件: * the method’s type is exported. * the method is exported. * the method has two arguments, both exported (or builtin) types. * the method’s second argument is a pointer. * the method has return
tech
在上一篇文章中,我用net/rpc 包实现了一个简单的 RPC接口,并且尝试了net/rpc自带的Gob编码以及JSON编码,学习了Golang RPC 的一些基本知识。本篇文章,我会将net/rpc 跟 protobuf结合起来,然后在了解一下如何使用Protobuf + 插件 生成 gRPC 的代码。 最后会尝试创建一个自己的protobuf插件来帮助我们生成代码,开始吧。 This article was first published in the Medium MPP plan. If you are a Medium user, please follow me on Medium. Thank you very much. 我们在工作过程中一定使用过gRPC + protobuf ,但是它们两个并不是绑定关系,
tech
Learn to implement a simple RPC interface in Go using the `net/rpc` package! 🚀 This article covers the basics and JSON encoding. Read more: https://dev.to/huizhou92/rpc-action-ep1-implement-a-simple-rpc-interface-in-go-1m96
go
Go 高性能编程 EP9: 逃逸分析. 从Go 编译器的角度来看,内存会被分配到两个地方: stack 和 heap 。对于业务开发人员来说,这两种方式,没什么区别,通常开发者并不需要关心内存分配在栈上,还是堆上,因为这都是编译器自动完成的。但是从性能的角度出发,在栈上分配内存和在堆上分配内存,性能差异是非常。
tech
Go 高性能编程 EP8: 如何通过优化GC来提高Golang代码的性能. 我们在用 golang 写程序的时候,一般不会去过分关注内存,因为 golang 运行时能够很好的帮我们完成GC 工作,但是如果遇到了需要性能优化的场景,我们能够了解一些GC 的知识,以及如何优化GC,会有很大的收益。 这篇文章,我们。
tech
Go High-Performance Programming EP8: Optimizing GC in Golang Using go trace. When developing with Golang , we typically don't focus too much on memory mana。